Download the PHP package wpackio/enqueue without Composer
On this page you can find all versions of the php package wpackio/enqueue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wpackio/enqueue
More information about wpackio/enqueue
Files in wpackio/enqueue
Package enqueue
Short Description API to enqueue assets generated by @wpackio/scripts into your WordPress plugin or theme.
License MIT
Informations about the package enqueue
WPACK.IO Enqueue API
This is the PHP companion of @wpackio/scripts
.
It gives you all the APIs you will need to properly consume assets generated from
@wpackio/scripts
from your WordPress plugins or themes.
Detailed Documentation
This README only covers the very basics and a quick start guide, without explaining the overall usage.
Please visit our official documentation site for detailed instruction.
Installation
Using Composer
We recommend using composer for using this library.
Then in your plugin main file or functions.php
file of your theme, load
composer auto-loader.
Manual
If you do not wish to use composer, then download the file Enqueue.php
.
Remove the namespace line namespace WPackio;
and rename the classname from
Enqueue
to something less generic, like MyPluginEnqueue
. This ensures
conflict-free loading.
Then require the file in your plugin entry-point or functions.php
file of your theme.
Getting Started
Which ever way, you choose to install, you have to make sure to instantiate the class early during the entry-point of your plugin or theme.
This ensures that we hava necessary javascript in our website frontend and admin end to make webpack code-splitting and dynamic import work.
A common pattern may look like this.
Default configuration when calling enqueue
main_js_handle
is added in 3.3 and can predictably set the handle of primary
JavaScript file. Useful for translations etc.
runtime_js_handle
is added in 3.4 and can predictably set the handle of the
common runtime JavaScript. This is useful to localize/translate dependent script
handles in the same files entry. By calling wp_set_script_translations
on the
runtime you can collectively enqueue translate json for all the dependencies on
the entries.
For information on usage and API, please visit official documentation site wpack.io.
Avoid conflict in multiple WordPress Plugins
Always require the latest version of Wpackio\Enqueue
. The autoloader is set
to load only one instance and will not conflict with existing class.
However, if you want to load conflict free, kindly use Strauss.
Actions and Filters
Filter wpackio_print_public_path
Accepts 3 parameters:
$publichPathUrl
The URL that is used for the publicPath$appName
Application Name$outputPath
Output path relative to the root of this plugin/theme.
Using this you can dynamically change the public path that is used for code splitting. This can be used to change the public path to a CDN.