View Full Version : HTTP requests versus filesize

name _F1
01-11-2008, 12:49 PM
I hear a lot about trying to reduce the number of HTTP requests that a web page makes, but I also hear about reducing the filesize of scripts and stylesheets to reduce page loading times.

Which is better; having a selection of different scripts and stylesheets and including them based on which is being used for that particular page (reducing the amount of bandwidth) or combining them all into one file and including that on every page (reducing the number of HTTP requests).

Is it any different when I am using iframes? I have one page that includes a few different frames. Between them, the frames reference about five different scripts (between 0 and 3 scripts per frame). Again, is it better to have a universal script file, or separate stylesheets referenced by the frames which need them?

01-11-2008, 05:38 PM
You'll have to make a balanced choice. I read an article once describing the amount of time the browser took making HTTP requests versus actually downloading the file on a fast connection--and the request was longer

01-11-2008, 08:25 PM
Personally, I've found it better to combine multiple scripts and CSS files—where appropriate—and use gzip on the server for compression.

01-12-2008, 01:44 AM
Thanks for the thread, i had this in mind!

I have to add a question, would you guys rather include the 2kb menu into each 15kb page, or rather have every page ~17kb?

I am using a 2kb menu as an example, but i am including kinda large lists (60-70kb, and i am being careful on size).

[ out of topic : i think iframes are really innapropriate uses as of 2008. Ever tried printing information included in an iframe? I did. Ever tried going back in the history while browsing a iframed website? I hope you never did. Considering there are better (maybe not easier) ways to achieve the same, i believe this task belongs to the developper. ]


01-12-2008, 02:08 AM
Includes will theoretically slow the page down. But they're easier to maintain. I prefer to use them.

01-12-2008, 02:35 AM
Whether it will be faster to make requests for more files or for fewer bigger files will depend on:

A. How much the extra files are reused by additional web pages so as to be able to reuse them from the cache rather thatn reading the same file multiple times (depends on how many of your pages a given visitor visits).

B. Depends on the connection speed of a given visitor - those on a faster connection will get a faster download from fewer bigger files while those on slower connections may get a faster download from more smaller files.

You have to find the appropriate balance to suit the connection speed and viewing habits of your typical visitor.

01-12-2008, 05:57 PM
Do includes make HTTP requests? I asked my mate about it and he said they were fileserver movements rather than requests. I always took his word.

01-12-2008, 06:41 PM
Do includes make HTTP requests? I asked my mate about it and he said they were fileserver movements rather than requests. I always took his word.

Depends, server side includes are done on the server and as such, don't involve any extra requests. But client side includes like referencing stylesheets and scripts, do require additional requests.

Keep in mind though that generally speaking things like your stylesheet will get cached by the client's browser after the first page view and won't be re-requested on other pages that use the same stylesheet.