Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created March 24, 2015 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsmith/971c2fab9442aab0a2ae to your computer and use it in GitHub Desktop.
Save wpsmith/971c2fab9442aab0a2ae to your computer and use it in GitHub Desktop.
<?php
wp_register_script( 'head-load', "/wp-includes/js/head.load$suffix.js", array(), '1.0.3', 0 );
wp_register_script( 'my-head-loader', "path/to/my/head.loader$suffix.js", array( 'head-load' ), '1.0.3', 0 );
$scripts = array(
'head' => 'wpHead',
'myJqueryFile' => "path/to/my/jquery.file$suffix.js",
'jQuery' => "//cdn.domain.com/jquery$suffix.js",
'underscorejs' => "path/to/underscore$suffix.js"
);
// Rename head to use wpHead.
wp_localize_script( 'head-load', 'head_conf', $scripts );
// Keep HeadJS defaults and do whatever I want
//wp_localize_script( 'head-load', 'prefixScripts', $scripts );
wp_enqueue_script( 'my-head-loader' );
wpHead.test("undefined" !== typeof jQuery, [prefixScripts.underscorejs, prefixScripts.myJqueryFile], [prefixScripts.jQuery, prefixScripts.underscorejs, prefixScripts.myJqueryFile], function(){
// Finally do something now that everything is ready!
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment