Created
January 18, 2024 01:52
-
-
Save mjones129/223a1533d690d78d110e1cf0bc16ebc7 to your computer and use it in GitHub Desktop.
Enable ES6 Modules for WordPress Themes JS
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('some-script-handle' === $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