Need to combine JQuery files to save load time

那年仲夏 提交于 2019-12-21 21:35:52

问题




I have the following JQuery libraries and I need to combine them in order to fasten up my web pages. Whats the best way and do some of them include the other ones in it, or can I find it some where, minified version that is.

JQuery.v1.6.4.js
jquery.tools.min.js
jquery-ui-1.8.16.custom.min.js
jquery.hoverIntent.minified.js
jquery.alphanumeric.pack.js
jquery.dcmegamenu.1.3.3.js
hero_image_slideshow.js

Thanks.


回答1:


You can use httpcombiner if you are using asp.net. http://archive.msdn.microsoft.com/HttpCombiner Or else you can use yui compressor http://developer.yahoo.com/yui/compressor/ http://www.refresh-sf.com/




回答2:


Take a look at Google Closure Compiler.

http://code.google.com/closure/compiler/

Not only can you use it to concatenate the files for you, it will do other optimizations including minification, etc.




回答3:


You can use require.js and its optimizer: http://requirejs.org/docs/optimization.html




回答4:


This is very related to a similar question about combining jscript files. A possible solution is compressJS, which uses the Google Closure Compiler in turn.




回答5:


  1. Combine and Minify JavaScript so that it is a smaller download and runs faster
  2. GZIP your JavaScript so it is a smaller download across the network
  3. Place your JavaScript on a CDN such as Akumai, Lime Light or Cloudfront

I do this for my ecommerce development business with very speedy results.




回答6:


Is server-side combine an option? In that case, what are you running the site on? If you're using .NET, I highly recommend Combres.

For PHP sites, try minify.

Scott Hanselman blogged about a batch script for the same purpose using AjaxMin. You could include that as part of a build script, for instance, if you can't/don't want to combine the files at runtime.

One of the benefits of on-the-fly combining/minifying is that you can decide to turn it off for requests from your IP address, for instance, so that you will always be able to read the original script, if you're debugging live code.




回答7:


Try out the online tools at jscompress.com it seems reasonably good.
You can either copy > paste your code in, or upload your js files and it will compress them for you.



来源:https://stackoverflow.com/questions/8512495/need-to-combine-jquery-files-to-save-load-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!