Issue #105

Sent to members on March 20, 2018

Another easy speed BOOST for your Wordpress site

I’ve got another slightly geeky (but still easy) hack you can make to give your blog another speed boost…

Yesterday’s issue of The Daily talked about removing orphaned settings from your WP_OPTIONS table to speed up your site.

In there, I talked how I initially ran a speed test on my site using GTMetrix. This is a nice service because it actually allows you to compare some of the other more common site speed tests like PageSpeed and YSlow.

One of the common things you’ll see pop up on these tests is something called dynamic query strings. The message will be something like:

The Edge Logo

Get THE EDGE Sent To You Every Monday!

Be sure to subscribe (for free) to have The Edge sent to you automatically every Monday morning. There’s some extra goodies in the email version you won’t find here in the archives. Just sayin’. 🙂

You will not be redirected from this post when you subscribe, so you can keep reading.

“Remove query strings from static resources”.

I know – nerdy! But, here’s what’s going on there…

A lot of Wordpress sites automatically insert query strings as a way to defeat caching and make the site load fresh each time. A query string is just something in the URL that contains some data after a “?” or “&” character. So, when your theme is pulling in various background files, it may have these query strings added – often with a version number or some other random thing.

So, as an example, if a plug-in were pulling in some kind of javascript file, it might use something like:

That little “?ver=2.5” thing is the query string. And when you run a speed test on your site, it may show you a big honker list of these things on you site.

Here’s the problem…

Google really cares about site speed. And, those query strings help to defeat the very cache that will speed up your site! So, a way to optimize the speed of your Wordpress site is to REMOVE those query strings!

The good news is that it is pretty easy to do. I’ll show you a plug-in way to do it and a non-plugin way to do it (since I don’t like a long plug-in list if I can help it).

A number of plug-ins can take care of this for you.

Once is called, creatively, Remove Query Strings From Static Resources. I give them an A+ for naming creativity there. 😉 I mean, seriously.

If you use W3 Total Cache, it has an option for this built in called “Prevent caching of objects after settings change”. Uncheck that.

Speed Booster Pack does a number of things to help with speed, including removing query strings.

Lastly, you can check out the WP Performance Score Booster.

Now, let me show you how I did it without using any plug-in at all. It requires adding a few lines of code to the functions.php file of your theme. Those lines are:

function _remove_script_version( $src ){ 
$parts = explode( '?', $src );     
return $parts[0]; 
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); 
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );​

Just add that to your theme and problem solved without adding more plug-ins to the mix.

As always, back things up before making changes like this.

But, speedy blogs satisfy the Google gods. 😉 Solving this little issue of query strings helps move the needle your direction.

– David

Tech Talk

Leave a Reply