Mayur
Mayur

Reputation: 3097

Combining JavaScripts files

I'm using a blogger platform for blogging. I've many widgets on my blog which refer to JavaScript files on the different servers, which is affecting loading performance of my blog.

Can I combine those files into one in order to reduce my requests to those servers? Or is there any other way to optimize my JavaScript code?

Upvotes: 1

Views: 161

Answers (2)

Ned Batchelder
Ned Batchelder

Reputation: 375484

The semantics of Javascript are such that you can simply concatenate a number of script files and they will execute the same.

BUT: you are loading 62 different scripts from a variety of sources. Many of those sources are likely loading dynamic content onto your page, meaning that if you copy the file once and concatenate it into a static file, you will be breaking the larger system of which the script is a part. Also, since these are APIs from third-parties, even if they look static now, you have no way of knowing when they might update their code.

Concatenate and compress your own code, but leaving others' alone is probably best.

Upvotes: 0

Sjoerd
Sjoerd

Reputation: 75578

Yes. Typically, the files are concatenated and minimized.

Upvotes: 1

Related Questions