screenshot

HTML/CSS/Javascript to Minimize:


Input to the Minifier is not stored on our server. For details, please see our Privacy Policy

Share: Share on Twitter Share on Facebook

Minimized Output:

⇩ Save Minified output

About the Minifier

Code minification is the process of removing unnecessary characters from a section of code while leaving the code's original functionality in tact. The end result is a new file which is smaller in size to the original, yet identical from the machine's perspective. Smaller files require less bandwidth, and have shorter load times on the web. This can reduce server resources and lead to a more pleasant user experience which is why minifying files is often cited as a best practice for web development.

This Web Minifier can minify HTML with embedded PHP, JavaScript and CSS*, as well as pure JavaScript* and CSS*

*The articles linked to describe an earlier version of this minifier, one with slightly less capabilities.

This minifier is designed to accommodate:


Important Details

Minification may seem straight forward, but is deceptively complex. While there are many simple approaches (like condensing white space) that can have a big impact on code size, perfect minification would require the ability to understand code from a functional level, and predict all possible outputs from all possible inputs. In fact, it is mathematically provable that a program to achieve perfect minification cannot exist by reducing it to the Halting Program.

Another Gotcha is that the nature of web languages, especially JavaScript, can often break naive minification tools. If one isn't careful minification can interfere with Automatic Semicolon Insertion, modify string literals and regular expressions, and inadvertently extend comments to include code. In fact, the reason I wrote this Minifier is that I grew tired of using free, open source Minifiers that broke my code!

The Minifier can minifying HTML, CSS and JavaScript. Since minification is primarily a benefit for data sent to the client, and PHP is executed sever side, we leave embedded PHP untouched. We also leave string variables untouched.

Assumptions the Minifier makes while Minifying HTML:

To understand why these assumptions are important, please see our article on Minimizing HTML with embedded PHP, JavaScript and CSS.

Datayze uses third party cookies to analyze our traffic (Google Analytics) and serve personalize ads (Google AdSense). We also set our own cookie when you acknowledge this message so we can stop showing it to you.

For instructions on how to revoke consent/acknowledgement, or opt out, please visit our Privacy Policy.

Privacy Policy