When viewing lots of webpages' source code (like JS,CSS,HTML), I find them in one line. How did they make this? Do they use some tools to make it? Can we restructure it?
Thanks.
When viewing lots of webpages' source code (like JS,CSS,HTML), I find them in one line. How did they make this? Do they use some tools to make it? Can we restructure it?
Thanks.
Share Improve this question edited Jun 18, 2012 at 4:52 Arnold Spence 22.3k7 gold badges76 silver badges67 bronze badges asked Jun 18, 2012 at 4:48 JasonJason 3631 gold badge8 silver badges19 bronze badges 3- 3 They are minified. Google for YUI compressor and look at jsbeautifier.org – zerkms Commented Jun 18, 2012 at 4:50
- 2 Minification, lots of it is discussed here in SO. – deex Commented Jun 18, 2012 at 4:51
- Or called Uglify – Derek 朕會功夫 Commented Jun 18, 2012 at 4:56
5 Answers
Reset to default 8It's minified HTML, i.e. with the whitespace removed.
There are many tools that can do this, you can find them by Googling for minify HTML.
To un-minify it or beautify it as they say, you can google for beautify HTML.
The same applies to CSS. It can be minified and beautified.
Javascript can also be minified however most tools nowadays obfuscate the symbols which means that although you could beautify it, it will be harder to understand it afterwards.
The alternative to Javascript minification is the Javascript Packer
Using Minify technique
Some free tools also available
http://developer.yahoo.com/yui/compressor/
http://www.minifycss.com/minify-tools/minify-css-tools.php
http://jscompress.com/
http://www.minifycss.com/css-compressor/
http://code.google.com/p/htmlcompressor/
It combines multiple CSS or Javascript files, removes unnecessary whitespace and comments, and serves them with gzip encoding and optimal client-side cache headers.
This is a result of using g minification tools. The intention is to make the JavaScript as small as possible so it can download as quickly as possible.
YUI compressor is one and there are many more available.
Code of JavaScript, CSS etc are one liner to be specific 'compressed' to remove the extra spaces from the code.. This reduces the size of the file thus loading time of the css or javaScript file reduces...
There are many tools that are use to compress the code for e.g. http://javascriptcompressor.com/
i think uglify.js is good tool which minifies the js code. refer this link https://github.com/mishoo/UglifyJS , worth learning..