Magento News
Magento – HTML minify code causing some javascript not working
I have the below code to remove white space in a Magento site.
ob_start("htmlcompress");
function htmlcompress($buffer) {
$buffer = preg_replace('/nr|rn|n|r|t| {2}/', '', $buffer);
return $buffer;
}
It works well, however in some areas where inline javascripts are used, the scripts stopped working. Example, in “checkout/onepage/billing.phtml”:
<script type="text/javascript">
//<![CDATA[
$('billing:region_id').setAttribute('defaultValue', "<?php
echo $this->getAddress()->getRegionId()
?>");
//]]>
</script>
and “giftmessage/inline.phtml” where toogle function disabled; also the “payment/form/cc.phtml” where radio button for payment options.
Not all inline scripts got disabled though, for instance, anything start with “var” are working.
How I can improve the compress script to prevent javascript from stop working?
Thanks
Magento – HTML minify code causing some javascript not working
Possibly Related Posts:
- Database query different results
- Menu highlight in magento under admin
- magento disable a banner on certain category pages or have a banner with multiple links
- Magento, using ACL for frontend. Possible?
- Magento IE-7 Fix In Windows XP
RSS Feed