What steps will reproduce the problem? 1. Include Javascript with CDATA in HTML Document (Style 2, see coming text) 2. Compress HTML Document with Html Compressor 3. Javascript is not compressed
What version of the product are you using? 0.9
Hi there,
according to the W3C xHTML Specification (http://www.w3.org/TR/xhtml1/ , section 4.8) Javascript should be put into cdata to validate successfully:
<script type="text/javascript"> <![CDATA[ ... unescaped script content ... ]]> </script>
To avoid confusing older browsers the cdata tags are often put into comments like: Style 1: <script type="text/javascript"> /* <![CDATA[ / ... unescaped script content ... / ]]> */ </script>
or Style2: <script type="text/javascript"> //<![CDATA[ ... unescaped script content ... //]]> </script>
It would be very nice for htmlcompressor to adhere script put into cdata.
Comment #1
Posted on Feb 6, 2010 by Grumpy HippoFixed in 0.9.1, but partially.
What's fixed is if JS block is wrapped with CDATA then it will be compressed
correctly. But if CDATA is put inside comments (for older browsers) those comments
will be treated as regular comments and removed by YUI. I can't solve this properly
without writing JS parser, so if you want to keep browser compatibility and CDATA,
then a workaround would be either disabling inline JS compression all together or
putting inline JS into external files.
Style tags wrapped in CDATA blocks were handled by YUI correctly already, but again if you put CDATA inside comment they will be removed. Maybe this feature should be handled on YUI compressor side better.
Thanks.
Status: Fixed
Labels:
Type-Defect
Priority-Medium