简体   繁体   English

缩小/组合JS文件

[英]Minify/Combining JS Files

I have around 6-7 javascript files that I want to minify and combine. 我有大约6-7个javascript文件,我想缩小和组合。 I have been minifying my javascript here: http://www.minifyjavascript.com/ 我一直在缩小我的javascript: http//www.minifyjavascript.com/

I am having a little difficulty "combining" my javascript. 我有一点困难“结合”我的JavaScript。 By combine, am I just copy and pasting all the javascript to one huge js file? 通过组合,我只是复制并粘贴所有的JavaScript到一个巨大的js文件? If I do this, I will end up with around 1000 lines of code and I have to figure out exact dependencies. 如果我这样做,我将最终得到大约1000行代码,我必须弄清楚确切的依赖关系。 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? 另外,我是否必须将jquery等脚本与我的脚本结合起来?

Any help would be appreciated. 任何帮助,将不胜感激。

There is the Closure Compiler from Google, that will combine JS files and minify them to a level of your choosing. 有来自Google的Closure Compiler,它将结合JS文件并将它们缩小到您选择的级别。 It certainly saves a great deal of playing about with cutting & pasting which, as you probably know, can get very complicated. 它肯定会节省大量关于剪切和粘贴的游戏,正如您可能知道的那样,它可能变得非常复杂。

I just use Notepad++ and the JSMin plugin. 我只使用Notepad ++和JSMin插件。 I would just copy them in the order in which you include them in your html files. 我只是按照你在html文件中包含它们的顺序复制它们。

And no, I would not combine jsquery plugin with it. 不,我不会将jsquery插件与它结合起来。 Keep them separate so you can update independently of them. 将它们分开,以便您可以独立更新它们。

Check out PackScript. 查看PackScript。

http://danderson00.blogspot.com.au/2013/01/packscript-next-generation-build-for-web.html http://danderson00.blogspot.com.au/2013/01/packscript-next-generation-build-for-web.html

It does all you need and much more. 它可以满足您的所有需求。

Check this python script. 检查这个python脚本。

http://github.com/hkasera/minify http://github.com/hkasera/minify

It minifies js as well as css files too. 它也缩小了js和css文件。 It stores detailed log files and you can add this script as a git hook and save yourself from doing it manually everytime. 它存储详细的日志文件,您可以将此脚本添加为git钩子,并避免每次手动执行此操作。

Hope it may help! 希望它可能有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM