Results 1 to 6 of 6

Thread: Compact HTML

  1. #1
    Join Date
    Dec 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Compact HTML

    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

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    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...
    - Mike

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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/
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •