缩小/组合 JS 文件
我有大约 6-7 个 javascript 文件,我想缩小和合并它们。我在这里缩小了我的javascript: http://www.minifyjavascript.com/
我遇到了一点困难“组合”我的javascript。通过合并,我是否只是将所有 javascript 复制并粘贴到一个巨大的 js 文件中?如果我这样做,我最终会得到大约 1000 行代码,并且我必须找出确切的依赖关系。有没有一个简单的在线程序可以为我做到这一点?另外,我是否必须将 jquery 等脚本与我的脚本结合起来?
任何帮助将不胜感激。
I have around 6-7 javascript files that I want to minify and combine. I have been minifying my javascript here: http://www.minifyjavascript.com/
I am having a little difficulty "combining" my javascript. By combine, am I just copy and pasting all the javascript to one huge js file? If I do this, I will end up with around 1000 lines of code and I have to figure out exact dependencies. Is there an easy program online that can do this for me? Also, do I have to combine scripts such as jquery with my scripts?
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Google 提供了 Closure Compiler,它将合并 JS 文件并将它们缩小到您选择的级别。它确实节省了大量的切割和切割工作。您可能知道,粘贴可能会变得非常复杂。
There is the Closure Compiler from Google, that will combine JS files and minify them to a level of your choosing. It certainly saves a great deal of playing about with cutting & pasting which, as you probably know, can get very complicated.
我只使用 Notepad++ 和 JSMin 插件。我只是按照您将它们包含在 html 文件中的顺序复制它们。
不,我不会将 jsquery 插件与它结合起来。将它们分开,以便您可以独立于它们进行更新。
I just use Notepad++ and the JSMin plugin. I would just copy them in the order in which you include them in your html files.
And no, I would not combine jsquery plugin with it. Keep them separate so you can update independently of them.
查看 PackScript。
http://danderson00.blogspot.com .au/2013/01/packscript-next- Generation-build-for-web.html
它可以满足您的所有需求,甚至更多。
Check out PackScript.
http://danderson00.blogspot.com.au/2013/01/packscript-next-generation-build-for-web.html
It does all you need and much more.
检查这个 python 脚本。
http://github.com/hkasera/minify
它也缩小了 js 和 css 文件。它存储详细的日志文件,您可以将此脚本添加为 git hook,从而避免每次都手动执行此操作。
希望它能有所帮助!
Check this python script.
http://github.com/hkasera/minify
It minifies js as well as css files too. It stores detailed log files and you can add this script as a git hook and save yourself from doing it manually everytime.
Hope it may help!