[英]Could someone explain how I can combine my JS and CSS files?
I have done my research on combining JS and CSS files. 我已经完成了关于组合JS和CSS文件的研究。 I am still a novice when it comes to all of this so the explanation like some of these minifies and compilers at Github and Google don't really make sense in normal English.
对于所有这些,我仍然是一个新手所以像Github和谷歌这样的一些缩小和编译器的解释在普通英语中并没有真正意义。
I have the following CSS files: 我有以下CSS文件:
These are my JS files: 这些是我的JS文件:
Which tool should I use and if someone could explain step by step that would be great. 我应该使用哪种工具,如果有人能够逐步解释那将是很好的。
If you want to just have one big js and cs file then you can just combine them into ones by copying and pasting the content of each file one after another, in the same order you would include them on a page. 如果你想只有一个大的js和cs文件,那么你可以通过一个接一个地复制和粘贴每个文件的内容,将它们组合成一个,按照你将它们包含在页面上的顺序。 Keep in mind that you do not need bootstrap if you are including bootstrap.min file after it.
请记住,如果您在其后面包含bootstrap.min文件,则不需要引导程序。 It's the same file, only the one with .min in name is minified version of it.
它是同一个文件,只有名称中.min的文件是它的缩小版本。 Same goes for js files.
js文件也是如此。
Then if you want... you can run a tool for compression like this one: http://refresh-sf.com/yui/ 然后,如果你想...你可以像这样运行压缩工具: http : //refresh-sf.com/yui/
and hope everything works fine. 并希望一切正常。
Though combining files is easy that not something you should do to libraries. 虽然组合文件很容易,但是你不应该对库做些什么。 Moreover for most cases you should not merge these files.
此外,对于大多数情况,您不应合并这些文件。
Libraries tend to stay unchanged for long time, thus will be eventually cached by user. 库通常会长时间保持不变,因此最终会被用户缓存。 Site loading time will be faster.
网站加载时间会更快。
A good approach is to link these libraries to 3rd party CDNs (Google, JQuery, etc.). 一种好的方法是将这些库链接到第三方CDN(Google,JQuery等)。 They are far better with load balancing and this will increase your page loading time.
它们在负载平衡方面要好得多,这会增加页面加载时间。 (There could be some DNS lookup overhead, though).
(但可能会有一些DNS查找开销)。
Larger files tend to skip the cache. 较大的文件往往会跳过缓存。 So having large file can make your page significantly slower if every next page call will download the library again.
因此,如果每次下一次调用都会再次下载库,那么拥有大文件会使页面显着变慢。
Of course for your custom script joining in single file and minimization will almost always be recommended. 当然,对于您的自定义脚本加入单个文件并且几乎总是建议最小化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.