Created
February 5, 2024 14:36
-
-
Save mjones129/4e3ae86f0d06dd73c0c85be2e7ba2a59 to your computer and use it in GitHub Desktop.
Load JS modules as ES6 in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
//load as ES6 | |
function load_as_ES6($tag, $handle, $source) { | |
if('tagname' === $handle) { | |
$tag = '<script src="' . $source . '" type="module" ></script>'; | |
} | |
return $tag; | |
} | |
add_filter('script_loader_tag', 'load_as_ES6', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment