Jump to content

ProCache omitting the body tag when minifying HTML


andy-jfd
 Share

Recommended Posts

Hello Andy,

actually this is not an issue, because the body-tag, like many others, is optional and can be stripped out to reduce the markup:

Quote

body element's start tag may be omitted if the element is empty, or if the first thing inside the body element is not a space character or a comment, except if the first thing inside the body element is a metalinkscriptstyle, or template element.

Source: https://www.w3.org/TR/html5/syntax.html#optional-tags

Ryan's blog post about the HTML minification of ProCache: http://processwire.com/blog/posts/processwire-2.6.9-core-updates-and-new-procache-version/#major-enhancements-to-html-minify-capabilities

Regards, Andreas

  • Like 1
Link to comment
Share on other sites

Quote

Certain tags can be omitted.

In my mind, the word can should be in bold here. Just because you can, doesn't mean you should. Omitting the <body> tag, whilst saving a couple of bytes opens a can of legacy worms. Older browsers will revert to quirksmode and Google Analytics 'prefers' analytics code immediately after the <body> tag. 

The module is awesome, and has shrunk down the first site we built to be so quick, the web inspector barely keeps up, but this one seems like it should be optional in ProCache to help with legacy development.

What do you think Andreas?

 

  • Like 2
Link to comment
Share on other sites

My opinion is simple here:

Yes some tags can be omitted, but I especially draw the line at the body.

How hard does the browser have to work in order to calculate a document with such tags omitted? 

Doesn't seem worth it for the sake of a few bytes in my honest opinion...  

  • Like 1
Link to comment
Share on other sites

I agree that it should be optional. I found similar issue with input type text where "type" was removed so my CSS rules targeting input[type="text"] failed. But most cases there's a setting where you can fix such things, but of course that means you need some experience in ProCache.

As a workaround if you add a class to the body it should be kept (untested).

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Hi @andy-jfd. Just wanted to mention for future reference that you should post ProCache-related questions to the ProCache VIP support area. If you don't have access there but have bought ProCache, please let Ryan know and I'm sure he'll be happy to add you. Thanks!

Link to comment
Share on other sites

  • teppo locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...