PHP function for compacting html?

Discussion in 'PHP' started by fcmisc, Apr 21, 2008.

  1. #1
    Hey,

    What's the best php function for compacting html?

    From what I've read, "tidy" has problems with Drupal, which is what I use.

    I've also found this:

    http://php100.wordpress.com/2006/10/30/html-compact/

    But am wondering if there's anything else I could try that's better?

    Cheers,

    fcmisc.
     
    fcmisc, Apr 21, 2008 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    It's not worth the effort if you ask me, especially if you already use GZip compression. GZip averages compression rates of 50-75% off text based files and I'm not exactly sure on the technical details of GZip compression but compacting HTML will not be reflected proportionately in GZip compressed file size resulting in less effect.

    If you want to save every last byte, you can go and use non-compliant code, 2 letter code names for all your class names, JS variables etc. like you see on the Google home page but for most sites, this is not necessary nor worthwhile.
     
    krt, Apr 21, 2008 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    It depends on how it looks before compression attempts are made.

    One example is if code is indented neatly for developer readability a lot of bytes can be reclaimed by removing the tabs from the beginning of lines. I believe Blogger does this.
     
    joebert, Apr 23, 2008 IP