Mantle provides a fluent wrapper on-top of WordPress' enqueue system. It relies on the wp-asset-manageropen in new window package to provide a number of flexible methods for asset registration.
Mantle includes a
Asset_Service_Provider class for managing asset registration. Assets can be registered in any of your service providers, too. You can use the
Asset facade or the
asset() helper method to quickly access the API:
Assets can be enqueued in a fluent-basis on top of the existing WordPress API:
asset()->script( 'example-handle', mix( '/js/app.js' ) );
Assets can also be made to load with
asset() ->script( 'example-handle', mix( '/js/app.js' ) ) ->async() ->defer();
The location the asset appears can also be controlled:
asset() ->script( 'example-handle', mix( '/js/app.js' ) ) ->header(); asset() ->script( 'example-footer', mix( '/js/footer.js' ) ) ->footer();
You can also specify the asset's version and dependencies:
asset() ->style( 'example-styles', mix( '/css/app.css' ) ) ->version( '1.0' ) ->dependencies( [ 'unicorn-css' ] );
Mantle includes Laravel Mixopen in new window by default to manage assets.