Skip to content

Instantly share code, notes, and snippets.

@roelven
Created March 20, 2011 19:12
Show Gist options
  • Save roelven/878571 to your computer and use it in GitHub Desktop.
Save roelven/878571 to your computer and use it in GitHub Desktop.
wp enqueue scripts + headJS
// Enqueue Javascripts
// Replace jQuery 1.4.4 with 1.5 on the frontend
// as seen on http://codex.wordpress.org/Function_Reference/wp_enqueue_script
// Do not do this on the wp-admin, jQuery 1.5 might break functionality at this point (March 2011)
function rv_enque_scripts() {
// get theme to use that for versioning and cache busting
$theme = get_theme(get_current_theme());
if (!is_admin()) {
// remove jQuery 1.4.4
wp_deregister_script('jquery');
// Register jQuery 1.5 + other scripts
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js', '', $theme['Version']);
wp_register_script('gAnalytics', 'http://www.google-analytics.com/ga.js', '', $theme['Version']);
wp_register_script('cufon', get_bloginfo('template_directory').'/js/cufon-yui.js', 'jquery', $theme['Version']);
// Do not load the Cufón font here, since we can't control dependencies with this HeadJS plugin. In stead load timely in script.js
// wp_register_script('cufon-Clarendon', get_bloginfo('template_directory').'/js/Clarendon_LT_Std_700.font.js', 'cufon', $theme['Version']);
wp_register_script('rv_app', get_bloginfo('template_directory').'/js/script.js', 'cufon-Clarendon', $theme['Version']);
// Enqueue the scripts in the preferred order
wp_enqueue_script('jquery');
wp_enqueue_script('cufon');
wp_enqueue_script('cufon-Clarendon');
wp_enqueue_script('gAnalytics');
wp_enqueue_script('rv_app');
}
}
add_action('init', 'rv_enque_scripts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment