Title: HTML compression
Last modified: December 22, 2016

---

# HTML compression

 *  Resolved [iRolfpro](https://wordpress.org/support/users/irolfpro/)
 * (@irolfpro)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/html-compression-2/)
 * I can see many weird line breaks in compressed HTML like:
 *     ```
       <div
       id="mainsearch"><div
       class="search-form-box"><form
       role="search" method="get"
       ```
   
 * I can’t figure out any algorythmic or logic behind this. could this be improved?
 * thank you for your feedback,
    rolf

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Raul P.](https://wordpress.org/support/users/alignak/)
 * (@alignak)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/html-compression-2/#post-8581126)
 * Hi,
 * What’s your exact concern about this?
    Are you possibly getting a warning to 
   minify html on gtmetrix or some other score website?
 * That code looks like your source viewer is just wrapping the text on your window,
   so it doesn’t look like a linebreak. It goes down possibly due to the screen 
   width, browser settings or server settings (there are ways to enforce line breaks
   after xx chars for compatibility with some very old browsers).
 * What happens when you copy paste the source onto a notepad file and disable line
   wrapping?
    Are those still there?
 * Also, how does your theme files look?
    Are these specific linebreaks already 
   on the theme?
 * Is this html you’re showing me, inside a <script></script> tag or is it being
   loaded with ajax?
    Linebreaks are preserved inside script tags for javascript
   compatibility (those matter in javascript code). As for ajax requests, I believe
   those are not processed since the plugin only targets the main html page (ajax
   would be a module or extra element loaded by javascript).
 *  Thread Starter [iRolfpro](https://wordpress.org/support/users/irolfpro/)
 * (@irolfpro)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/html-compression-2/#post-8581293)
 * when I copy the code to an editor I got several lines.
    every line in the example
   above is a line of its own in the editor (Atom, to drop a name). and that are
   short lines, no need to break in nearly any window width.
 * when I use a plugin like Minify HTML allthecommentsaregoneandtagsareconcatenatedinonesingleline.
   
   whithout linebreaks. but it’s one more plugin on the list that I could get rid
   off to keep the total number of plugins small.
 *  Plugin Author [Raul P.](https://wordpress.org/support/users/alignak/)
 * (@alignak)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/html-compression-2/#post-8581440)
 * I’ll take a better look at the html minification library (third party) but what
   I can see is that whitespace is being replaced by linebreaks inside html tags…
   it could be that linebreaks have a smaller footprint than whitespace, but it 
   makes the source a bit strange (but I care more for performance and size, not
   beauty of code).
 * If this behavior is something I can change without compromising speed, I’ll release
   it before Christmas on a new version.
 * As for js files and large css files, some browsers need frequent linebreaks for
   things to work smoothly. For example, if you use the Google Compiler for JS minification,
   this happens:
    [https://developers.google.com/closure/compiler/faq#linefeeds](https://developers.google.com/closure/compiler/faq#linefeeds)
 * > The Closure Compiler intentionally adds line breaks every 500 characters or
   > so. Firewalls and proxies sometimes corrupt or ignore large JavaScript files
   > with very long lines. Adding line breaks every 500 characters prevents this
   > problem. Removing the line breaks has no effect on a script’s semantics. The
   > impact on code size is small, and the Compiler optimizes line break placement
   > so that the code size penalty is even smaller when files are gzipped.
 * YUI Compressor usually makes it into a single line… but then it causes trouble
   with long files.
 * Browsers also have limits for css, most notabily IE. If you have too many css
   rules in one file it will break. [http://stackoverflow.com/questions/9906794/internet-explorers-css-rules-limits](http://stackoverflow.com/questions/9906794/internet-explorers-css-rules-limits)
 * This means that we cannot simply minify all css or js into one single line.
 *  Thread Starter [iRolfpro](https://wordpress.org/support/users/irolfpro/)
 * (@irolfpro)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/html-compression-2/#post-8582345)
 * wow, cheers and thank you for the insights.
    weird stuff.
 * kind regrads – and enjoy christmas!
    rolf
 *  Plugin Author [Raul P.](https://wordpress.org/support/users/alignak/)
 * (@alignak)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/html-compression-2/#post-8641782)
 * I am pushing an update today and I’ll include a fix for this.
 * Thanks.
 *  Thread Starter [iRolfpro](https://wordpress.org/support/users/irolfpro/)
 * (@irolfpro)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/html-compression-2/#post-8645048)
 * works like a charme. thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘HTML compression’ is closed to new replies.

 * ![](https://ps.w.org/fast-velocity-minify/assets/icon-128x128.jpg?rev=1440946)
 * [Fast Velocity Minify](https://wordpress.org/plugins/fast-velocity-minify/)
 * [Support Threads](https://wordpress.org/support/plugin/fast-velocity-minify/)
 * [Active Topics](https://wordpress.org/support/plugin/fast-velocity-minify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fast-velocity-minify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fast-velocity-minify/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [iRolfpro](https://wordpress.org/support/users/irolfpro/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/html-compression-2/#post-8645048)
 * Status: resolved