开发者

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.

C开发者_运维技巧an 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?


Yes. Typically, the files are concatenated and minimized.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜