Skip to content

Instantly share code, notes, and snippets.

@lloc
Created December 24, 2014 15:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloc/5a10f7f37e4851ca21c0 to your computer and use it in GitHub Desktop.
Save lloc/5a10f7f37e4851ca21c0 to your computer and use it in GitHub Desktop.
<?php
function my_enqueue_script() {
wp_enqueue_script(
'requirejs',
plugins_url( '/js/require.js', __FILE__ ),
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_script' );
function my_script_loader_tag( $tag, $handle, $src ) {
if ( 'requirejs' == $handle ) {
$app = plugins_url( '/js/app.js', __FILE__ );
$tag = "<script data-main='{$app}' src='{$src}'></script>\n";
}
return $tag;
}
add_filter( 'script_loader_tag', 'my_script_loader_tag', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment