JS - 无法合并lib文件 [英] JS - Can't combine lib files

查看:108
本文介绍了JS - 无法合并lib文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个index.html文件中有多个lib文件,这些文件按照正在运行的应用程序的顺序加载。

 <! - 其中一些例子...  - > 
< script src =/./sys/lib/jquery.min.js>< / script>
< script src =/./sys/lib/jquery.ui.min.js>< / script>
< script src =/./sys/lib/jquery.easing.min.js>< / script>
< script src =/./sys/lib/ underscore.min.js>< / script>
< script src =/./ sys / lib / handlebars.min.js>< / script>
< script src =/./sys/lib/bone.min.js>< / script>
< script src =/./ sys / lib / moment.min.js>< / script>
< script src =/./sys/lib/libs.extensions.js>< / script>

这些运行良好,它们已经全部缩小。



现在,我想将这些全部组合到一个文件中以加载速度:

 < script src =/ ./sys/lib/libs.all.js\"></script> 

所以我打开新的 libs.all.js 文件,并按照上面列出的完全相同的顺序,将缩小的.js文件一个一个粘贴到修改中。这工作,直到我到了moment.js。当我粘贴并运行它时,出现JS错误。

  TypeError :(中间值)(... )不是一个函数

我不明白我所缺少的 - 如果我将它们粘贴到正确的顺序,因为他们同步加载在HTML文件中,有什么区别? 大多数情况下,你的js文件中有一个丢失一个; 结尾。打开你认为会导致错误的那个,并在最后添加一个; ,或者添加一个; 到下一个js文件的第一行。


I have multiple lib files in an an index.html file, that are loaded in proper sequence for an app I am running.

<!-- example of some of them... -->
<script src="/./sys/lib/jquery.min.js"></script>
<script src="/./sys/lib/jquery.ui.min.js"></script>
<script src="/./sys/lib/jquery.easing.min.js"></script>
<script src="/./sys/lib/underscore.min.js"></script>
<script src="/./sys/lib/handlebars.min.js"></script>
<script src="/./sys/lib/backbone.min.js"></script>
<script src="/./sys/lib/moment.min.js"></script>
<script src="/./sys/lib/libs.extensions.js"></script>

These run fine, they are already all minified.

Now, I want to combine these all into one file for load speed:

<script src="/./sys/lib/libs.all.js"></script>

So I open up the new libs.all.js file, and one by one paste the minified .js files into it, with zero modification, in the exact same sequence as listed above. This works until I get to moment.js. When I then paste that in and run it, I get a JS error.

TypeError: (intermediate value)(...) is not a function

I don't get what I am missing - if I paste them in the right sequence as they synch loaded in the HTML file, what is the difference?

解决方案

Most probably one of your js files is missing a ; at the end. Open up the one you believe is causing the error and add a ; at the end, or add a ; to the very first line of the next js file.

这篇关于JS - 无法合并lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆