Forum Moderators: phranque

Message Too Old, No Replies

ever minify HTML on the fly?

         

tom12c

4:17 pm on Aug 4, 2010 (gmt 0)

10+ Year Member



I'm wondering if anyone here ever minified HTML using apache arguments.

Or is it more a manual process?

SevenCubed

4:34 pm on Aug 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you refer to "minifying html" I'm assuming you are trying to comply with the Page Speed Firefox plugin's suggestions?

If yes then it's a manual process to eliminate as much unnecessary markup code as possible. As an example, I've taken my own pages to the extreme by compressing them down to a single line of code after I am finished working on them! But even with that the tool still says I only have it down to about 94% "minified" -- hogwash! The only way to get it to 100% is to follow suggestions to remove some element closing tags and I will not do that because then the code isn't xhtml 1.1 compliant.

So, mostly it's a manual chore unless you want to compress the output to the client by using Apache gzip or deflate -- but that's compression and not "minifying".

tom12c

5:06 pm on Aug 4, 2010 (gmt 0)

10+ Year Member



You are quite right, I'm trying to comply with Page Speed Firefox plugin.

I've been looking around online to see if there was a clean solution for it. I would definitely not prefer doing it manually on every page that I have.

mhansen

5:16 pm on Aug 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have used a small script called SmartOptimizer very successfully. Free, easy to use, works great!

Not sure if I can drop a link in or not - here goes. [farhadi.ir...]

SevenCubed

5:28 pm on Aug 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then you would need to look for a text editor that can help you with that. As an example I use a freeware program called PSPad Edit (I hope I can say that here). After I am finished working on a page it has a one button click and "compress" that will bring your code down to a minimal amount mostly accomplished by removing white spaces. Whenever I need to work on the code again to make page changes I open the file and apply html formatting and it "uncompresses" it into a workable format, again done with one click.

But true "compression on the fly" is accomplished server side through Apache mod_gzip (version 1.3) or mod_deflate (version 2.x?). When a client requests a page from the server Apache will fetch it and compress a file sized 19K down to about 6K before sending it to the client. The server deflates it and then the client re-inflates it before rendering it in the browser.