So I get this question asked a lot through the Headway forums, or just people in general wanting to know how they can switch to loading jQuery from Google’s CDN of JS libraries. So I figured I’d post here.
In your Header file you need to add this:
[php]<?php wp_enqueue_script( ‘jquery’ ); ?>
<?php wp_head(); ?>[/php]
Then you need to add the following to your functions.php file:
[php]function load_jquery_google() {
wp_deregister_script( ‘jquery’ );
wp_register_script(‘ jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js’);
}
add_action(‘init’, ‘load_jquery_google’);[/php]
Feel free to change my function name with whatever you want to use.
Now the only thing you have to do is call your javascript using the no-conflic mode. Basically instead of using the $ shortcode you would do this:
[js]jQuery(document).ready(function({
// you code here
});[/js]
Hopefully this was useful for you!