Hack WordPress to speed it up – JQuery
WordPress by default comes bundled with the jQuery framework. You can find it in the wp-includesjsjquery directory. Many themes use this framework extensively for various effects and widgets alike. Unless you are on a dedicated server or are using a CDN, chances are that jQuery takes a whole lot of time to load. The best way is to speed up this process is to include the jQuery library from the Google’s Ajax Libraries API. Read on to learn how to include it in your theme:
Actually the method is quite simple. If your theme includes a direct jQuery call from the header.php (usually will be written like
or something similar) just delete the line.
If your theme designer had adopted efficient programming practices, he would have used the wp_enqueue_script() function. It can be identified by going to your Theme Functions (functions.php) file of your theme.
Now to include the script from Google’s Ajax Libraries API servers, just insert the following code into the Theme Functions (functions.php) file of your theme:
// smart jquery inclusion
if (!is_admin()) {
wp_deregister_script(‘jquery’);
wp_register_script(‘jquery’, (“http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”), false);
wp_enqueue_script(‘jquery’);
}
Once done, save the file and your done. To check if the change has occurred, load your blog’s home page (or any other page for that matter). Now press Ctrl+Shift+R to force refresh the page.
Now take a look at the page source (Ctrl+U or View => Source). If the following line appears, you have successfully included this hack into your wordpress blog:
The advantage of this hack is that your page loading times will get faster and in lieu better!