WordPress: Use Google Libraries instead of locally hosted ones
As I pointed out numerous times before: speed is important for any kind of operation on the Internet as a better loading performance will improve conversions on your websites. Mozilla managed to increase Firefox downloads by 60 million per year by shaving off 2.7 seconds of loading times on the organization's download pages.
While that is great in theory for a number of reasons, it means that users have to download those scripts when they connect to the service or website for the first time. There is one exception to the rule: if a script has not been modified and is already in the cache of the browser, it won't get downloaded again but loaded from the local browser cache.
One suggestion that developers had in recent time is to switch to remotely offered scripts instead of locally ones. And one of the prime targets for that is Google, as it is hosting numerous scripts on its fast content distribution network for anyone to use.
The benefit of using hosted versions of jQuery and other scripts are the following:
- Improved latency thanks to Google's impressive content distribution network that delivers the scripts from a location close to the user to decrease latency and speed up downloads
- Parallel downloads thanks to being offered from another server. This is especially important if users are working with browsers that limited simultaneous downloads from web servers to 2 connections.
- Better caching thanks to an increased likelihood that the script is already cached for users who connect to your website for the first time.
Especially the third option can speed things up for first time visitors, as the scripts do not have to be loaded at all if the user did download them on another web property previously before.
The WordPress plugin Use Google Libraries changes the location of several locally used scripts to Google hosted ones so that you and your site's visitors can benefit from this.
It is an install and forget about it plugin, as it handles everything in the background. There is no configuration to make, and you should check the effectiveness of the plugin by monitoring your website's network activity after plugin installation.
If you are using Chrome or Firefox, hit F12 and select Network from the tabs listing in the Developer menu that opens here. Reload the web page and look at the scripts that get loaded. You should notice that some get loaded from Google servers instead of the local server.
As far as support goes, the plugin for WordPress supports the following libraries and components right now:
- jQuery UI
If your website is using other scripts, they may still be loaded from the local server and not from the remote server.
One additional benefit from this operation is that you will save bandwidth. Some scripts have a size of 100 Kiloybtes or larger, which you save for every new connection made. If you get 1000 new connections per day, you are saving 100.000 Kilobytes per day, or 36.500.000 Kilobytes per year.
To sum it up: You increase the loading performance of your websites if supported scripts are being used, and at the same time reduce how many bandwidth your website requires.
The only caveat here is that you load resources from Google, which some may see as a privacy risk that they do not want to take.
The only concern I would have with doing this is would be the question of whether Google would ‘support’ this or not. You are essentially syphoning part of their bandwidth for your own use. And while your use may not be that much compared to their own daily use, every little bit counts.
Should they decide to (re)move or alter their libraries to suit their own needs, unless they are actively supporting your use of their copies of the libraries, things could fall apart rapidly for your site. And if you’ve happened to ‘forget’ that you installed this, it could be a pain to troubleshoot where the problem is coming from.
Your worries are unfounded to say the least.
Google encourages you to use their hosted libraries, that’s why they set up the CDN to begin with.
Good advice, Martin! I always use Google scripting for jQuery rather than the local WordPress code since most people will have it cached, making their experience on the site faster.
All seems good until an update to the Google library causes other plugins to break, and then you’re in the soup!
They keep all versions available as far as I know.
Thanks for the recommendation of the plugin. I believe many developers are suggesting the same plugin as well.
I am speechless with the enormous difference this made on a WP site that was just painful to use on the admin side. On the forward facing side load times are amazingly faster as well!