All features

Cherry Blossom feature

Frontend Enqueues: Script Generic

Registers a JavaScript asset from an enqueue definition.

Registers a JavaScript asset from an enqueue definition.

Capabilities and extension points

Class for any generic script

This is used for most scripts. Can be extended.

Sets up the Script_Generic object.

Based on the args, all properties will be set. At least a location or file (url) is required.

  • param string $handle The handle of the script.
  • param array $args The arguments for the script.

When using the file path, with filemtime we can use an

actual filemtime. This is great for files that change more frequently and automatically deals with browser cache.

This should not be used for core files, since they do not change unless CHERRY_BLOSSOM_VERSION changes anyway.

When testing (or when script_debug is enabled), we will always try to use the filemtime.

Sets a supported WordPress script loading strategy.

Unsupported values leave the current strategy unchanged.

  • param string|null $strategy Defer, async, or null.

Source reference

This editable reference page is based on the PHP documentation in frontend/enqueues/class-script-generic.php.