admin管理员组文章数量:1245094
I need a tool which can minify, optimize and munge many files of those possible types
- HTML (minify only)
- JavaScript (minify, optimize and munge)
- CSS (minify)
The final result should be one HTML file only with all JavaScript and CSS embedded or in the worst scenario 3 files respectively for HTML, JS, and CSS.
I am aware of tools like YUI Compressor etc. What I currently have not found is the type of pressor which will work on all those file types and merge them in one huge file only.
I need a tool which can minify, optimize and munge many files of those possible types
- HTML (minify only)
- JavaScript (minify, optimize and munge)
- CSS (minify)
The final result should be one HTML file only with all JavaScript and CSS embedded or in the worst scenario 3 files respectively for HTML, JS, and CSS.
I am aware of tools like YUI Compressor etc. What I currently have not found is the type of pressor which will work on all those file types and merge them in one huge file only.
Share Improve this question asked Jun 28, 2010 at 20:34 Gad D LordGad D Lord 6,77212 gold badges63 silver badges110 bronze badges 5- 1 Currently experimenting with Digua (digua.sourceforge) – Gad D Lord Commented Jun 28, 2010 at 20:47
- Question: how the hell can u merge all that into ONE file? ... unless all of those are already in one file, to start of with? – Pure.Krome Commented Jul 4, 2010 at 11:42
- They can be merged easily with a batch/bash script by appending one after another. – Gad D Lord Commented Jul 10, 2010 at 15:49
- 9 It is not optimal to have JS+CSS embedded in HTML. It costs more network bandwidth when you have multiple HTML pages sharing the same JS+CSS. – BalusC Commented Jul 16, 2010 at 23:39
- 1 What about offline document? Pdf file still requires reader while html can be displayed on virtually all devices. – Tomas Tintera Commented Jun 24, 2016 at 6:29
7 Answers
Reset to default 2If you're not using gzip yet, start using it already and we can close this thing out ;)
My suggestion would be to put all of the JavaScrpt inside a <script>
in the header, and put all of the CSS in a <style>
tag as well. Then optimize to the best of your ability and then minimize it on your own. No software will ever be able to handle every case. If you are trying to minimize the file size then just remove the newlines and non-necessary spaces.
I also found this, which should work on your file with all 3 in it.
Also be aware that if you start removing optional tags you could run into some problems. Some browsers don't cooperate as well as they are supposed to.
Gad, consider the drawbacks to minifying CSS. If you don't have a system where you edit normal/minify/ then deploy it can make later editing of CSS rather dicey.
I went through this whole argument on a big UI refresh project for an international bank. One site in particular was doing 1million+ visitors/day and bandwidth numbers were insane despite all our efforts to keep it minimal (every little bit adds up on a site that heavily trafficked) Upon business analysis by a large team of very talented minds, it was determined that we would take several steps, but NOT css minifying due to the added time it would take engineers to undo the minifying before fixing, minifying and redeploying for simple CSS tweaks. The numbers showed that even with a 5gb/day bandwidth improvement, it was still cheaper to not pay a UI engineer for the extra time.
We don't know your site's specifics, but there aren't terribly many that have to worry about the traffic my example uses. Run your site in Firebug's new speed analyzer and see what the real benefit could be from minifying.....now multiply that by your traffic. Usually, that number isn't too scary. Spend your time doing image sprites, bining css and js into respective files (better than mashing into individual php files due to caching benefits) to limit http requests, and ensuring that caching is properly setup. Run gzip pression. If after those steps you're not good, then take the site to a new level.
Keep it simple....it makes a huge difference in the update and maintenance portions of the site's lifecycle. With the time and headache saved, you can help us out with our questions :)
As far as I know there isn't such a tool. If you use PHP on the server side, however, you can try PHP Speedy (not actively developed, but works) or Minify for automated minification, caching and gzipping (HTML, CSS, JS).
edit: kangax's HTML minifier (as Badger suggested) only does HTML minification.
you can use jsCompressor to press and minify multiple JavaScript files and CSS Compressor to press/minify multiple Css files into one file. and to optimize your HTML files you may send post request of your code to Google Clouser server which sends response with optimized Html code.
http://prettydiff./?m=minify will do exactly what you need, except that it only minify JavaScript and not obfuscate it.
I suggest you look at the build script that's included in the html5 Boilerplate: http://html5boilerplate./. With some minimal tweaking it'll do what you're looking to do.
本文标签: HTMLJavaScriptCSS compact toolStack Overflow
版权声明:本文标题:HTML + JavaScript + CSS compact tool - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740210119a2241839.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论