Log in

View Full Version : Compact HTML



asapcorp
03-24-2007, 08:32 AM
Hi all,

Is there any freeware/GPL tools available to compact html which will reduce the file size drastically, which will save our bandwidth?

Thanx

mburt
03-24-2007, 10:30 AM
The only way to efficiently reduce your code filesize, is to manually change it. HTML doesn't have an "encryption" option, or can't be compiled.
HTML is read as a plain ASCII text file, and shouldn't be that big of a file anyways...

jscheuer1
03-24-2007, 12:26 PM
I remember a program years ago that would do this by stripping out unnecessary carriage return/linefeeds, spaces and quotes. It wasn't always 100% reliable (sometimes broke the code) and produced HTML code that was almost impossible to read with the human eye. Even if you could read it, editing was a real hassle as, most of the lines were already at maximum length for your editor and couldn't have anything added to them.

Fortunately I forget what it was called.

A better strategy is to write clear and compact code. Keep style and scripts separate from markup and in external files. Optimize your code and images. Any savings beyond that would be minimal and (as I've indicated) counterproductive.

Here is a program that may help:

http://www.w3.org/People/Raggett/tidy/

Twey
03-24-2007, 02:12 PM
Make extensive use of CSS in your pages and, as John said, store scripts and styles in separate files. If your server has support for on-the-fly compression, turn it on.

jscheuer1
03-24-2007, 02:33 PM
More on external files, there is little point to using them if they are not used by more than one page. But, if they are, the savings will be that they only need to be parsed/loaded/cached once by the browser.

Twey's idea about using extensive css puzzles me. I think only the css required by your pages would be a greater savings than any inflated css but, I don't think that is what Twey really meant.

You should use style wherever possible to format your content. This allows you to load a master stylesheet(s) for the site and to leave out many, many attributes for individual elements on your pages.

Twey
03-24-2007, 02:58 PM
You should use style wherever possible to format your content. This allows you to load a master stylesheet(s) for the site and to leave out many, many attributes for individual elements on your pages.That's essentially what I was trying to say. Avoid presentational markup entirely.