Which is better for JavaScript load-time: Compress all in one big file or load all asynchronously?

It depends on what the site is and how important first load time is for it.

It depends on what the site is and how important first load time is for it. Regardless of that though, I'd probably load JQuery and stuff like that from a public CDN. One big benefit is that it might already be cached even if they have never been to your site.

encosia.com/2008/12/10/3-reasons-why-you... The Cappuccino team is a big proponent of one file -- they make a javascript framework. Apps made with their tool are expected to have some load time. cappuccino.org/discuss/2009/11/11/just-o....

Another benefit of loading JQuery and related from a public CDN would the increased requests by destination. I believe the client is restricted to 2 requests per domain, so by loading jquery from google, and a plugin from jquery, and your custom app code from your own domain, the browser can execute these concurrently rather than waiting for the first two and then issuing a third request. I guess this adds another performance improvement over one large file as well.

Even if you just split that 1 file into 2, it could be retrieved with 2 concurrent requests from the browser potentially improving load time.

Here's what we did to make our web app fast. The main JS and CSS files are compressed and put inline with the HTML markup. The white spaces of the HTML are removed and the images are converted to data:image/png by a shell script.

The size is ~400kb but cached and gzipped. The mobile version of the web app is the same but at ~250kb. It means the whole app is ready to run, like an executable, in a single http call.

Then a second http call get the data(JSON), and we use PURE to render it in HTML using the existing markups in the page as templates. The app is divided in modules, only the common modules are preloaded this way. The others are coming when requested by the user.

There is no exact answer to this question. It pretty much depends on how and when you are making use of those files. Typically, you only want to download JS files on pageload which are universally required by the web app.

Module specific or page specific JS files shouldn't be compressed in the main JS download and would ideally be loaded on demand. Also, this question is valid only if you are concerned about user experience for first time users. The JS files would be cached anyways for every other visit.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions