Mobile app version of vmapp.org
Login or Join
Angela700

: Is having one 7KB file faster to load than 6 files totalling 7KB? From a technical standpoint, the answer is also yes. To see why, I'd recommend downloading a web server (example: apache)

@Angela700

Is having one 7KB file faster to load than 6 files totalling 7KB?


From a technical standpoint, the answer is also yes. To see why, I'd recommend downloading a web server (example: apache) and run it on your own computer so that you access your pages locally. Heck, you should be doing this already before publishing the pages to the web in order to minimize guest inconveniences (which include one-time slowdown during website update).

Once you have apache, set it up to accept a maximum of 6 connections and put apache in prefork mode. I understand prefork isn't the best mode but using it is the best way to understand why the accepted answer is correct.

Now make a request for a webpage that loads 7 or more resources. You will notice that six will load very quickly as there are 6 connection slots available on the server. Now if you try to load the seventh, there will be a delay until one of the first six resources have finished loading.

To understand this visually, try to make your webserver public to the world temporarily or sign up for a host where you can modify the setup (renting a dedicated server would be perfect), and then request your page through webpagetest.org or pingdom.com and you'll see a waterfall showing how each element of the page is loaded. You will notice long bars for requests beyond the limit your server can handle at once (which in the example is 6).

So the best advice is to follow the recommendations and combine the javascript and even better, strip out comments and white space.

For example: This is not optimized javascript:

//This is a function

function whatever
(
)
{

//initialize a variable
var avariable;

//set a variable
avariable=1;

//give a message
alert("x");

}


and this is the same javascript optimized for file size:

function w(){var x=1;alert("x")}


Sorry software developers, I violated conventions by not properly indenting nor declaring variables camel case style, but I was focused on space saving.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme