views:

45

answers:

2

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?

+1  A: 

Yes. Typically, the files are concatenated and minimized.

Sjoerd
Can I combine those files into one file?
Mayur
Yes, you can just copy and paste them together, or you could use http://jscompress.com/
Sjoerd
@Mayur: Concatenated means combined. Just make sure the files are concatenated in the correct order so that certain things like function literals are not referenced before they exist.
Robusto
A: 

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.

Ned Batchelder