Filters the HTML script tag of an enqueued script.
Parameters
$tagstring- The
<script>tag for the enqueued script. $handlestring- The script’s registered handle.
$srcstring- The script’s source URL.
Source
$tag = apply_filters( 'script_loader_tag', $tag, $handle, $src );
Changelog
| Version | Description |
|---|---|
| 4.1.0 | Introduced. |
Useful when a script excecution depends on “ attributes, eg:
Scripts must be registered/enqueued via wp_enqueue_script()It can be used to defer or async all JS scripts :
You can also use the
$handleargument to filter scripts.