简体   繁体   English

有人可以解释我如何组合我的JS和CSS文件?

[英]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文件:

  • bootstrap 引导
  • bootstrap-min 引导敏
  • bootstrap-responsive 自举响应
  • bootstrap-responsive-min 自举响应分钟
  • main 主要
  • prettyPhoto prettyPhoto

These are my JS files: 这些是我的JS文件:

  • bootstrap 引导
  • bootstrap.min bootstrap.min
  • jquery jQuery的
  • jquery.prettyPhoto jquery.prettyPhoto
  • jquery-migrate-1.2.1 jQuery的迁移-1.2.1
  • theme 主题

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. 此外,对于大多数情况,您不应合并这些文件。

  1. Libraries tend to stay unchanged for long time, thus will be eventually cached by user. 库通常会长时间保持不变,因此最终会被用户缓存。 Site loading time will be faster. 网站加载时间会更快。

  2. 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查找开销)。

  3. 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.

相关问题 当有人试图在我的js目录中获取src文件时,有人可以解释这意味着** / * .js吗? - Can someone explain what this means **/*.js when trying to fetch the src files in my js directory? 什么时候应该合并我的JS和CSS文件? - When Should I Combine my JS and CSS Files? 有人可以向我解释为什么在脚本文件之前加载CSS文件时网页加载速度更快吗? - Could someone explain to me why a webpage loads faster when you load CSS files before script files? 有人可以解释一下谷歌主页JS吗? - Could someone please explain the Google homepage JS? 有人可以解释为什么我的功能不起作用吗? - Could someone explain why my functions are not working? 有人可以解释为什么我的JavaScript无法正常工作吗? - Could someone explain why my javascript is not working? 如何在TYPO3中压缩我的js / css文件 - How can I compress my js/css files in TYPO3 有人可以详细解释这段代码,我应该如何在我的 javascript 程序中运行它 - can someone explain this code in detail and how should I run it in my javascript program 有人可以解释一下如何在 Node.js 中调用回调吗? - Can someone explain how callbacks are invoked in Node.js please? 我收到“icons[0].addClass("change") 不是函数”的错误。 有人可以解释一下,我该如何解决这个问题? - I'm getting an error that "icons[0].addClass("change") is not a function". Can someone please explain me that, how could I fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM