On a website I found the following code:
<!-- Google Website Optimizer Conversion Script -->
<script type="text/javascript">// <![CDATA[
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')
// ]]></script>
I am wondering why the script tag is concatenated from two parts: '<sc'+'ript src="http' ..
Is that standard code from Google (the current code they supply looks different - maybe old code) ? Or did the webmasters customize it? What could have been the reason to do so?
It is separated in two parts so browser's HTML parser won't pick it up and treat it as closing (explicitly or implicitly) tag for current
<script>when this JavaScript is inserted in user's HTML.It is standard practice for any inline JavaScript that have strings
<script>or</script>in it and, obviously, it is not needed when you work with JavaScript placed in separate files.