Created
October 30, 2013 16:09
-
-
Save jonathanhudak/7235335 to your computer and use it in GitHub Desktop.
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
//functions.php | |
wp_register_script('livereload', 'http://localhost:35729/livereload.js?snipver=1', null, false, true); | |
wp_enqueue_script('livereload'); //keep this at the bottom | |
// this code creates a variable for your template assets path for use with require.js | |
$WP_DIRECTORY = array( 'path' => get_stylesheet_directory_uri() . '/js' ); | |
wp_localize_script( 'require', 'directory', $WP_DIRECTORY ); | |
// ADD DATA ATTRIBUTE TO ENQUEUE SCRIPT | |
add_filter('clean_url','requirejs_script',10,2); | |
function requirejs_script( $url ) { | |
if ( // comment the following line out add 'defer' to all scripts | |
FALSE === strpos( $url, 'require.js' ) | |
) | |
{ // not our file | |
return $url; | |
} | |
// Must be a ', not "! | |
return "$url' data-main='".get_template_directory_uri()."/js/global'"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment