PDA

View Full Version : Calling CSS and js in head tags


urbanrays
11-12-2010, 10:40 AM
Hi

Just another quickie

Was just wondering how much you put in your head tags to help loading times, I have a couple of css sheets and call 4 different js/something.js scripts, included in the js I am calling js/jquery.min.js

So my question is when do you start calling the js from the bottom of the page to help loading times?

The other js files are very small so they shouldnt hamper to much time.

And could I also add I keep seeing something like

http://ajax/something_google (http://ajax/something_google) to call the jquery.min, is this the normal way to do it or does it not really matter?

Thanks for any help

gentleone
11-12-2010, 11:50 AM
For the jQuery library I also use the hosted version on google api. The benefit of this that users that visit a google api site before (which is a lot of users) they have already the jQuery library in their cache.

If you have a lot javascript files its best practice to minify them and to combine them to one js file.

http://www.speedingupwebsite.com/2010/03/03/javascript-combine-and-minify-troubles-and-solutions/

EDIT: here's an online tool
http://jscompress.com/

urbanrays
11-12-2010, 12:57 PM
For the jQuery library I also use the hosted version on google api. The benefit of this that users that visit a google api site before (which is a lot of users) they have already the jQuery library in their cache.

If you have a lot javascript files its best practice to minify them and to combine them to one js file.

http://www.speedingupwebsite.com/2010/03/03/javascript-combine-and-minify-troubles-and-solutions/

EDIT: here's an online tool
http://jscompress.com/


Thanks for that, will have a look at the links now thank you, I got visions of the yellow triangle already combining all the js together, but will have a go.

gentleone
11-12-2010, 03:28 PM
It's all about reducing the amount of HTTP requests. The more there are the slower the page load. If you use also a lot of background images in your CSS, then the CSS sprites technique is your friend to reduce the amount of HTTP requests.
http://www.smashingmagazine.com/2009/04/27/the-mystery-of-css-sprites-techniques-tools-and-tutorials/

Here is another online tool to merge js files and it does also do CSS files. Very useful.
http://www.scriptalizer.com/

domedia
11-12-2010, 03:42 PM
It's all about reducing the amount of HTTP requests. Amen. This is what a lot of people don't realize.

Corrosive
11-12-2010, 03:47 PM
Amen. This is what a lot of people don't realize.

Export from Photoshop spacer.gif anyone?