Speed Up WordPress By Using the WordPress.com CDN for Javascript Files

speed
photo credit: Tc Morgancc
Here’s a quick performance tip for self-hosted WordPress sites. WordPress loads a number of scripts from its /wp-includes/ directory, depending on what you have active on your site. Use WordPress.com Libraries is a new plugin, created by Automattician and plugin developer Ben Lobaugh. Once installed, it automatically switches the URL on built-in WordPress Javascript files to serve them from the WordPress.com CDN instead. Rather than taxing your local server, you offload those requests to WordPress.com, thereby decreasing load time and bandwidth consumption.

Here’s a quick sample of a site’s scripts before installing the plugin:

<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.10.3'></script>
<script type='text/javascript' src='http://example.com/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.10.3'></script>
<script type='text/javascript' src='http://example.comm/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js?ver=1.10.3'></script>

The plugin automatically changes the script URLs in use to call the ones hosted on WordPress.com:

<script type='text/javascript' src='http://wordpress.com/wp-includes/js/jquery/jquery.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://wordpress.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>
<script type='text/javascript' src='http://wordpress.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.10.3'></script>
<script type='text/javascript' src='http://wordpress.com/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.10.3'></script>
<script type='text/javascript' src='http://wordpress.com/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js?ver=1.10.3'></script>

Don’t look for a settings panel, as it doesn’t come with any options. You simply install the plugin, activate it and you’re good to go. Everything happens automatically in the background. As a general warning, make sure to check through your site after installing this in case anything has broken. In my tests everything worked fine but if you’re running an older version of WordPress, it may not work predictably. The plugin is still in development and will likely receive updates to improve it over time.

It’s tough to say how much of a performance boost you’ll get and how much bandwidth you’ll save by installing this plugin, because it depends on which scripts you have active on your website and how heavy your traffic is. However, every small bit helps, especially if you’re not already using a CDN. Install the Use WordPress.com Libraries plugin for free from the WordPress plugin directory.

Who is Sarah Gooding


Sarah Gooding is an Editorial Ninja at Audrey Capital. When not writing about WordPress, she enjoys baking, knitting, judging beer competitions and spending time with her Italian Greyhound.

There are 17 comments

Comments are closed.