Enqueues MU Plugin is designed to make modern WordPress asset management effortless, scalable, and maintainable. Here’s why developers love it:
-
Automatic, Context-Aware Asset Loading:
- Loads CSS/JS for each page type, template, or post type automatically, with smart fallback to defaults. No more manual enqueues for every template.
- Block editor assets (blocks, plugins, extensions) are registered and loaded based on context and naming conventions.
-
Performance & Maintainability:
- Caching for asset lookups and template scans means fewer filesystem hits and faster page loads.
- Minified assets are served in production, unminified in dev for easy debugging.
- Inline asset support for critical CSS/JS reduces render-blocking requests and improves perceived performance.
-
Extensible & Customizable:
- Every aspect is filterable: dependencies, localization, handles, versions, media, directory structure, and more.
- Modular controller-based architecture lets you enable/disable or extend features as needed.
-
Modern Build Integration:
- Webpack JS utilities generate entry points and copy patterns automatically—no more manual config updates when adding new files.
- Block editor assets are organized in scalable, maintainable subfolders.
-
Developer Experience:
- Local dev warnings for missing builds help you catch issues early.
- Autoloading and config management with environment-specific overrides.
- Fully documented, standards-driven codebase.
-
Security & Best Practices:
- All input is validated/sanitized, and output is escaped using WordPress best practices.
- Custom code lives in MU-plugins, not in theme files, for clean separation and easier updates.
Enqueues MU Plugin is a modern, flexible system for automating and customizing asset loading in WordPress themes and plugins. It is designed for maintainability, performance, and extensibility—supporting both classic and block-based development.
Note: All Webpack automation features are optional. You can use only the PHP asset loading/controllers, or only the Webpack utilities, or both together. Loading and initializing controllers is also optional and context-dependent—see Quick Start for details.
- Automatic Theme Asset Loading: Load CSS/JS for each page type, template, or post type—automatically, with smart fallback.
- Block Editor Integration: Register custom blocks, block categories, and block editor plugins with fine-grained control.
- Webpack Automation (Optional): Dynamically generate Webpack entries, copy assets, and extract dependencies for a seamless build process. All Webpack features are optional and can be used independently.
- Inline Asset Registration: Easily add critical CSS/JS directly to your page head or footer.
- Extensive Filters & Extension Points: Customize every aspect of asset loading and block integration.
- Troubleshooting & Advanced Usage: Solutions for common issues and advanced scenarios.
- Install via Composer
composer require thecodeco/enqueues:dev-main
- Initialize in your theme or plugin (Optional)
You only need to initialize controllers if you want to use the automated PHP asset loading features. You can use the Webpack utilities or other features independently.
\Enqueues\enqueues_initialize_controllers('theme');
- Start customizing!
- See Theme Asset Filters for examples.
- Automatic Asset Loading:
The plugin detects the current page type, template, or post type and loads the corresponding CSS/JS file. If no specific file is found, it falls back to
main.js
/main.css
. - Block Editor Features: Easily register and manage custom blocks, block categories, and block editor plugins. Use filters to control dependencies, localization, and more.
- Webpack Automation (Optional): Utilities help you keep your Webpack config in sync with your codebase, automatically generating entries and copying assets. You can use these utilities without using the PHP controllers.
- Inline Asset Registration:
Register critical CSS/JS for inline output in
wp_head
orwp_footer
. - Extensive Filters: Fine-tune every aspect of asset loading, block registration, and build output. See the docs for a full list.
- Theme Asset Loading →
- Block Editor Features →
- Webpack Automation →
- Inline Asset Registration →
- All Filters & Usage →
- Troubleshooting →
For a full list of filters, advanced configuration, and real-world usage, see the relevant sections in each doc in the /docs/
folder.