开发者

Simple merge of the js files caused errors and jquery being undefined

I'm dealing with a pure js front-end here and tried to use Juicer today to compress the javascripts. It worked fine thought without minification since there are tons of errors in libraries I use found by JsLint the validator of which is essential to pass in order to have files minimized. I left it as is since that wou开发者_如何学运维ld be cool to have at least merging working but it seems not to be the case. Though eventually all the files were indeed merged into one, app stopped working since jquery is considered undefined. In the file is stays on the first place though.

What could be the possible reason for such a strange behavior? Thanks a lot in advance for your answer!

UPD Here is a link to the merged file


Since you only want to merge them and not minify them, maybe try merging them manually. It's just:

cat file1.js file2.js file3.js > all.js

It's the same for CSS, no fancy merging is needed.

For minification of JavaScript I recommend UglifyJS because it tends to not break code unlike some other tools. UglifyJS is used by jQuery.

When you merge the JavaScript files by simple concatenation what's important is the order of the files to not break dependencies. Another thing that sometimes causes problems are missing semicolons (those can break the code after minification) or missing newlines at the end of the files.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜