开发者

JavaScript files that are concatenated fail

I have been looking at combining my JavaScript files into one file, to gain some performance. Mostly it worked like a charm, but not for the jquery.templates, knockout.js and knockout.mapping.js libraries.

I have tried something as simple as manually copy/pasting the content of the three files into one file. As soon as I reference that new file instead of the three original files it fails - with undefined is not a function, but the error is not as important as why there is any difference a开发者_C百科t all.

Any idea why this happens?


Check strict mode tags in all files. If the first has it but later ones don't strict mode will be enabled for everything, or the other way round.


Probably there is no line break at the start or the end of the files, which can lead to problems when they are concatenated.

Also, it can be that the order of the files must be correct. For example when file 1 contains function "Test" and file 2 uses this function.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜