Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable JS Compression within CDATA #8

Closed
GoogleCodeExporter opened this issue Aug 20, 2015 · 1 comment
Closed

Enable JS Compression within CDATA #8

GoogleCodeExporter opened this issue Aug 20, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

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.






Original issue reported on code.google.com by werner.g...@gmail.com on 6 Feb 2010 at 11:32

@GoogleCodeExporter
Copy link
Author

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

Original comment by serg472@gmail.com on 6 Feb 2010 at 6:47

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant