WordPress page load time tweaks ended in … failure

Why was I trying to speed it up on a first place. Well, some of you might be aware of the fact that me and my Family moved to Sydney. We will be here until May. My blog and my hosting is in UK. Broadband in Oz is far below random average back in UK. I was never bothered to check my own blog for response time as it was always good. Trying to load my blog main page I was shocked waiting for few minutes for it to appear on a screen.

The beginning and general enthusiasm

What I did is a little analysis on a page with Firefox and YSlow. It turned out that a lot of time takes for JavaScript files to load. About 8 files that are not too big but for some bizarre reason takes ages. YSlow suggested to combine them into one file and compress.

That’s fine. Sounds like a plan. Grab all the JS files combine them into one and then compress. Turned out more complicated than one would think.

There was no JavaScript that comes with bare WordPress to compress and combine with other files. The JavaScript that I got on my blog was the one from additional plugins I have installed.

After a quick googling I found out that there is a WordPress plugin for JavaScript compression. It is called WP_JS. It works quite sweet, whenever you got a JS file and you need to add it to your post all you do you put this line:

<script src="<?php wp_js('path/to/js/file.js'); ?>"type="text/javascript"></script>

The problem with this one is that it will only work for a files from within your current theme folder.

JS files I would like to compress into one file are those inside plugins. Seems like WP JS doesn’t have access to that. Oh well, first hack then. Copy all the files to one folder that would be accessible to JavaScript compression plugin.

imageWhen I finished I had to go trough all the plugins and comment out the JavaScript imports. Finished with this task I moved to getting all the JS files in a header as one compressed file. So in other hands all the plugin JavaScripts would be compressed and loaded in one file.

When I done that it turned out that there are JavaScript errors on a page. Some plugins are spitting more to a HTML then just a JavaScript imports and they depend on a stuff inside those imports. In other words, one big mess. Impossible to decouple and extract as one file.

Good idea

It would be absolutely awesome if I could apply some sort of a filter for a HTML content before it is being spit out to a browser, grab all the JS imports, create one big JS on a flight, compress it and then send to a browser.

With a knowledge I got about WordPress it seems impossible at the moment.

Failure and what I ended up with

So I ended with disabling plugins. There is only few enabled with very little JavaScript.

Last final solution is to redo the plugins so the JavaScript they are using will be suitable for a single file compression.

I don’t have time for that, so … no plugins instead 🙂

Take care, Gregster

Ps. I’m not going to try to achieve anything similar with CSS :-

3 thoughts on “WordPress page load time tweaks ended in … failure

  1. f you wanna optimize your internet performance, i suggest downloading dsl speed, it can boosts internet connection, thereby speeding up your computer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s