Laissez google faire le hosting de votre Jquery – wordpress

Google hosts a couple of well known scripts, like prototype, mootools and jquery. As the latest version of Jquery is ~90kb, it is necessary that it loads fast.

The best way to achieve that is let google host your scripts. In this way, wherever in the world your site is visited, the nearest google server will serve the script and will be much faster than a visitor for example from Belgium visits a site hosted in America.

This google page gives us the power to choose the scripts: http://code.google.com/intl/nl-BE/apis/libraries

This is the code of Jquery:

name: jquery
load request: google.load(« jquery », « 1.6.4″);
extras: uncompressed:true (as in google.load(« jquery », « 1.6.4″, {uncompressed:true});
path: https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
path(u): https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js
site: http://jquery.com/
note: 1.2.5 and 1.2.4 are not hosted due to their short and unstable lives in the wild…

What you need to do now is integrate this in your wordpress website. Every theme does that on his own, and you have to bypass that. So we are putting this line of code in the very source of every wordpress installation (not depending on the theme).

Go to the script loader.php file in your wp-includes folder and search for this line:
$scripts->add( ‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, false, ’1.6.1′);

Make it this:
$scripts->add( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js’, false, ’1.6.4′);

Tadaaa ! :)

Google hosts a couple of well known scripts, like prototype, mootools and jquery. As the latest version of Jquery is ~90kb, it is necessary that it loads fast.

The best way to achieve that is let google host your scripts. In this way, wherever in the world your site is visited, the nearest google server will serve the script and will be much faster than a visitor for example from Belgium visits a site hosted in America.

This google page gives us the power to choose the scripts: http://code.google.com/intl/nl-BE/apis/libraries

This is the code of Jquery:

name: jquery
load request: google.load(« jquery », « 1.6.4″);
extras: uncompressed:true (as in google.load(« jquery », « 1.6.4″, {uncompressed:true});
path: https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
path(u): https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js
site: http://jquery.com/
note: 1.2.5 and 1.2.4 are not hosted due to their short and unstable lives in the wild…

What you need to do now is integrate this in your wordpress website. Every theme does that on his own, and you have to bypass that. So we are putting this line of code in the very source of every wordpress installation (not depending on the theme).

Go to the script loader.php file in your wp-includes folder and search for this line:
$scripts->add( ‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, false, ’1.6.1′);

Make it this:
$scripts->add( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js’, false, ’1.6.4′);

Tadaaa ! :)

Google hosts a couple of well known scripts, like prototype, mootools and jquery. As the latest version of Jquery is ~90kb, it is necessary that it loads fast.

The best way to achieve that is let google host your scripts. In this way, wherever in the world your site is visited, the nearest google server will serve the script and will be much faster than a visitor for example from Belgium visits a site hosted in America.

This google page gives us the power to choose the scripts: http://code.google.com/intl/nl-BE/apis/libraries

This is the code of Jquery:

name: jquery
load request: google.load(« jquery », « 1.6.4″);
extras: uncompressed:true (as in google.load(« jquery », « 1.6.4″, {uncompressed:true});
path: https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
path(u): https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js
site: http://jquery.com/
note: 1.2.5 and 1.2.4 are not hosted due to their short and unstable lives in the wild…

What you need to do now is integrate this in your wordpress website. Every theme does that on his own, and you have to bypass that. So we are putting this line of code in the very source of every wordpress installation (not depending on the theme).

Go to the script loader.php file in your wp-includes folder and search for this line:
$scripts->add( ‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, false, ’1.6.1′);

Make it this:
$scripts->add( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js’, false, ’1.6.4′);

Tadaaa ! :)

About Benwake

I'm Benoît, working as a System Engineer for a big company. Webdesign is one of my biggest passions. I hope you'll enjoy this website. Do not hesitate to contact me if you have some questions about something or if you have comments (info@benwake.com). I speak fluently English, Dutch, French and German