I'm having an issue with Magento not processing script tags correctly:

This code:

echo $this->getChildHtml('addthisJs');

adds this script tag:

<script type="text/javascript" async src="//s7.addthis.com/js/250/addthis_widget.js#pubid=<?php echo $this->getAddThisPubId(); ?>"></script>

but on the page it seems to regards the "//" as a comment and then the rest of my html gets eaten by the script tag:

<script type="text/javascript" async src="</div></div></div></div></div></main><footer...

This is from the Magefan Blog extension, but I have this working just fine on another site, so I don't think there is any issue with the extension itself. Both sites are 2.1.0 but one works and one doesn't.

I can fix it by changing the "//" to "https://" but I really want to know why it doesn't work like it should on one site. There must be some underlying problem that could be having other nasty effects..

Why does starting the src with "//" cause this problem?

  • Could it be that its parsed as XML? <![CDATA[]]> tags are usually used on scripts to make sure it's not parsed as xml. – oscarpas Aug 19 '16 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.