I will show you little code How To Replace jQuery of WordPress in your Theme with Google AJAX Library, like we all know, WordPress has built in a lot of JavaScript Framework included jQuery, but for some reason such as Sever Speed or better handling, we need replace original jQuery for WordPress and using Google AJAX Library.
To use this featured is simple, we need put some code in our functions.php and your WordPress will use Google AJAX Library. Let’s get started
function jQuery_Google_init() {
if ( !is_admin() ) { // actually not necessary, because the Hook only get used in the Theme
wp_deregister_script( 'jquery' ); // unregistered key jQuery
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.4.2'); // register key jQuery with URL of Google CDN
wp_enqueue_script( 'jquery' ); // include jQuery
}
}
// For Themes since WordPress 3.0
add_action( 'after_setup_theme', 'jQuery_Google_init' ); // Theme active, include function
On this example, we use wp_enqueue_script() to do this tricks, thanks for WP Engineer to share it, now you can Replace jQuery of WordPress with Google AJAX Library more easier right?




Pingback: wp-popular.com » Blog Archive » Replace jQuery of WordPress with Google AJAX Library # WordPress Tricks & Tips
Pingback: WordPress jQuery durch die Google AJAX Library ersetzen
Pingback: WordPress Themehacks » WordPress jQuery durch Google AJAX Library ersetzen
Why do you think we should do this? Is it any better?
Pingback: The Creative Solution to Insert Google Analytics on WordPress | WordPress News Wire
You can also use the same trick to remove the need for jquery in the embed script when embedding surveys into wordpress using Rational Survey.