Move JS into footer (wordpress)

Hi,

Am struggling with speed on my site getting a overall grade of F from Yslow…

I read that moving JS into the footer can help this… how would i go about it? I found a plugin that was supposed to do this but I don’t think it works with wordpress 9 cause am still getting a F for Javascript :~

Thanks

www.leehughes.co.uk

Putting js in the bottom is not really the thing that I would start with.
It’s better to do first things that affect users of your site, such as combining js files, you currently have 27 different js files (plus css), and minifying them if possible. This will make your site load much quicker. If you can enable gzip conmpression on your server.
After that you need to setup expire headers for js/css, since I don’t think you modify them often.
This will bump your load speed and your YSlow grade.

right ok…

There is a minimise tool on firebug yes?

Yes I have heard of GZIP and I have to do that via my server?
Thanks

For minifying you can use jsmin. Gzip should be enable on your server for specific request (like js/css files), if you have apache mod_deflate is the module for this.
Expire headers you can write in apache (if you have linux host).
Just to be clear you will need eventually to put as much js as possible into footer, since it will make additional improvements.

Ok thanks…

I have a vague idea about what you’re on about… I shall do my best :0

Thanks

Ahh crap. that jsmin is a windows based program… am on mac

I don’t know if you read it already, but you can click on category titles in YSlow and it will go to pages with description of each problem and some way to solve it.

I think you can get C source here and compile it on mac? not sure though
http://www.crockford.com/javascript/jsmin.html

on the same link there is java, php and other versions, I think you can use one of those on mac

yeah, that’s beyond me lol

you can try one of these online minifiers:
http://jscompress.com/ or http://fmarcia.info/jsmin/test.html

Ahh that’s better :slight_smile:

Thanks

If you visit http://rakaz.nl, you will find a method (using PHP) to automatically put all your JS files into a single one, so that you only make one HTTP request. This is one of the main bottlenecks (HTTP requests). The same can be done with CSS.

Ok so I found it and it what http://rakaz.nl/projects/combine/combine.phps

What do I do with that??

Sorry, am not up with this sort of stuff, as you might have guessed :stuck_out_tongue:

You don’t even need to look at that PHP source. Just follow the instructions, which basically involve three things:

  • Make an .htaccess file and put it in your base directory, with the mod_rewrite code from the instructions in it
  • Build your JS/CSS URI as explained in the instructions
  • Put the PHP file in the root and then run it.

Right, ok thanks

Will give it a go in the morning when my eyes don’t sting :wink: :slight_smile:

I’m all too familiar with that stinging sensation! :frowning:

[ot]

Aren’t we all? :lol: [/ot]

Update… av found a neat little plugin called WP Minify that takes my yslow grade from F to C…

only problem is that it messes my css up http://i45.photobucket.com/albums/f56/phi21/Screenshot2010-01-07at233614.png

But still, pretty good eh… still working on getting it to A

Just thought I’d throw it out there that I wrote an article on minifying your js on the server side:
http://boedesign.com/blog/2009/12/02/serverside-javascript-minifying/