Skip to content

Instantly share code, notes, and snippets.

@mjones129
Created February 5, 2024 14:36
Show Gist options
  • Save mjones129/4e3ae86f0d06dd73c0c85be2e7ba2a59 to your computer and use it in GitHub Desktop.
Save mjones129/4e3ae86f0d06dd73c0c85be2e7ba2a59 to your computer and use it in GitHub Desktop.
Load JS modules as ES6 in WordPress
<?
//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