Possible Duplicate:
Why split the <script> tag when writing it with document.write()?
The Google DFP mobile init code contains this:
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
How is this any better than doing:
document.write('<script src="' + src + '"></script>');
In some cases where Javascript is processed or handled -- for example when the code is embedded into an HTML page -- the character sequences </script and <script are processed separately, before the Javascript is parsed to identify string constants and the like.
Therefore it is more robust to make sure that Javascript code one writes never contains these character sequences. It is arguably a good defensive habit to do this even for code that is not currently being processed by systems that would be broken by </script> -- because that will prevent problems in case the code is later copy-pasted into a context where </script> does produce a problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With