Asset Manager is a toolkit for managing front-end assets and more tightly controlling where, when, and how they're loaded.
Download a tagged release, install it into your plugins directory, and activate it on the plugins screen.
Or install with Composer:
composer require alleyinteractive/wp-asset-managerThe am_enqueue_* functions take the same parameters as their core WordPress equivalents, plus a few of their own. Options can be passed as an array or as individual parameters.
// Load a CSS asset asynchronously.
am_enqueue_style(
[
'handle' => 'site-styles',
'src' => 'css/styles.css',
'deps' => [],
'condition' => 'global',
'load_method' => 'async', // 'sync', 'inline', 'async'
'version' => '1.0.0',
'load_hook' => 'wp_head',
'media' => 'all', // 'print', 'screen', or any valid media query
]
);Full API reference lives in the wiki:
- Enqueue Functions —
am_enqueue_script,am_enqueue_style, and the full list of enqueue options. - Conditions — control when an asset loads, and register your own conditions.
- Inline Assets — print file contents or global JavaScript variables into the document.
- Preload —
am_preloadand its options. - SVG Sprite — register, display, and manage SVG symbols in a sprite sheet.
- WordPress: 6.3+
- PHP: 8.3+
You can view Asset Manager's official releases here.
The production branch is the latest stable release. The production-built branch tracks the same release with dependencies included, for sites that install the plugin directly from Git.
Bug reports and pull requests are welcome. See CONTRIBUTING.md for setup, tests, and coding standards.