Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

javascript - JS - Can't combine lib files

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...