paolochiodi / htmlcompressor

A work in progress port of google's htmlcompressor.jar
Other
150 stars 26 forks source link

Minifying JavaScript with yui is causing JS errors with <![CDATA[ #30

Closed iamcarrico closed 9 years ago

iamcarrico commented 9 years ago

When we add JavaScript into rails, it automatically adds in the //<![CDATA[ wrappers around the JavaScript. When we run the compressor with this:

<script>
//<![CDATA[
  function() { ... }
//]]>

It outputs this:

<script><![CDATA[function() { ... }]]>

which causes the function not to run. yui will removes the CDATA.

This PR just removes the code that will re-add in a CDATA around the code. If we feel it is necessary to put it back in, I suggest adding a comment wrapper around them and making it optional.

iamcarrico commented 9 years ago

Note: failure is from whitespace I believe— not sure how to create the same whitespace after playing with it for a while.

hlascelles commented 9 years ago

You're right, this needs fixing. Another PR has it passing Travis? https://github.com/paolochiodi/htmlcompressor/pull/33

iamcarrico commented 9 years ago

Fixed the issue— #33 and this to similar things. #33 just comments it out, I remove it entirely. Up to the maintainer which one is more desirable for the project.

paolochiodi commented 9 years ago

Hi, sorry for taking so long to act on this. I decide to go with the other PR on the same issue, because we are using CDATA only if it's already present in the original code. It would be unexpected to remove that in the minified version. It's also maintains the same level of compatibility with browsers.