var ga = document.createElement('script');
ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') +
'.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
While in the above code(in Google Analytics) ,
I wonder why they keep writing ga.type = 'text/javascript' ,
I’ve tried not adding it and it seems working well in modern browser
I thought I should have missed something
It used to be required to pass the XHTML validator (the
typeattribute). However, every modern browser parsedscriptblocks as JavaScript anyway.However, the HTML5 specification says you can leave it off, and it will default to
text/javascript.