As for how to detect XHTML, that may be a can of worms if you don’t use the doctype
The detection in HTML-minify.php (which is not mine, I just use it in AO) uses the doctype, but can be overridden to enforce XHTML and that’s what the new filter (‘autoptimize_filter_html_forcexhtml’) does. So I’m leaving the can of worms very much closed π
Anyway, thanks for looking into this. The more i think about it the less i think that html standards matter any more in html5, as long as it’s html of some sort.
Standards are important and validation is a tool (nothing more) to check adherence to those standards, but one should not be too … religious about them π
frank
Frank, i downloaded the zip from Github and that version appears to still be stripping out the CDATA.
~shanna
and so it should, by default, except when using the “autoptimize_filter_html_forcexhtml” to tell the minifier to consider the HTML as XHTML and if (when) & or <‘s are in the embedded script.
frank
Ok, yes the filter is working. But there is another problem here.
The block of JS that i pasted above (standard Google Analytics tracking code) is not getting filtered by your new filter, and it is not getting compressed and combined with other JS, even though there are no matches on the exclude list.
For other blocks of JS the filter and the compression/combining are working fine.
I sent you some screenshots. None of the options seem to be working on that last block of JS (the Google Analyics tracking code), and there are no matches with the exclude list.
I’ll have a look at the screenshots this weekend, but do take into account that;
1. some JS is hard-excluded from optimization (cfr. this line in autoptimizeScripts.php)
2. the HTML minifier only leaves the CDATA in place if the script contains one of the following characters/ sequences; “<“, “&”, “–” or “]]>”, cfr. this line minify-HMTL.php
But I’ll follow up on this (and test that filter myself, that might be somehow useful as well π )
have a nice weekend,
frank
Thanks for your patience on this. Perhaps those hidden JS exclusions should be more prominent. That is why the Google Analytics code is being excluded.
As for the CDATA, if the rules you listed above are also being applied when the XHTML filter is enabled, then yes, i would say it’s working – just not what i expected. However, i can’t see any problem with removing extraneous CDATAs if your rules are consistent with the XML standard (which i presume they are).
shanna
I had a look at the screenshots you provided and can indeed confirm your results are consistent with the code as outlined earlier.
Taking that into account, I will mark this topic as “resolved”, which off course does not imply you can’t follow up on this here π
frank
Yes, resolved. I’m with you on that. Consistent is good π and it seems to be that.