javascript - What Will Happen To Google Analytics Code Appearing Before The Head? -


I am now looking at a site that contains some Google Analytics code at an unusual location, i.e. & lt; Head & gt; tag.

Analytics is working properly ... but what will be the expected behavior for this?

Will JS be loaded instantly, before heading? If so, what effect does it have for (if any) what will be detected for it?

More commonly, & lt; Head & gt; and & lt; Body & gt; tag?

Any advice much appreciated.

Cheers.

And nowadays tags are parsed because they have to face without strict scrutiny. . Therefore any script (or any tag element for that matter, which is before & lt; head & gt; , but still & lt; html & gt; section section in the document, and something in the tag tag in the document gt if only valid tags are present, and pushed to body if text or invalid tags are found.

Such scripts, as long as they are & lt; head & gt; tags are OK (Since the head tag has changed now) it is normal, but unexpected behavior, and can also change between browsers and their versions. As soon as the browsers were developed, they were distracted by stringent standards Files and structures. You can confirm this by using the Developer Console (F12) in Chrome on this document:

  & lt ;! DOCTYPE html & gt; LT; html> & lt; script & gt; console.log (document.getElementsByTagName ('sh Rshk ')); & Lt; / Script & gt; & Lt; Top & gt; & Lt; Title & gt; This & lt; / Title & gt; As & lt; Script & gt; Var s = "sastra"; Console.log (s); & Lt; / Script & gt; & Lt; Title & gt; This2 & lt; / Title & gt; As & lt; / Head & gt; & Lt; Body & gt; & Lt; A href = "http://google.com" & gt; Click here for Google & lt; / A & gt; & Lt; P & gt; How are you? & Lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt; Viewing  

and calling document.getElementsByTagName ('html') and their head and body And compare it with the source in the same document given above, if 2 'etad' is replaced by & lt; Head & gt;

I mean:

  & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Script & gt; Console.log (document.getElementsByTagName ('title')); & Lt; / Script & gt; & Lt; Top & gt; & Lt; Title & gt; This & lt; / Title & gt; & Lt; Script & gt; Var s = "sastra"; Console.log (s); & Lt; / Script & gt; & Lt; Title & gt; This2 & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; A href = "http://google.com" & gt; Click here for Google & lt; / A & gt; & Lt; P & gt; How are you? & Lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

You will see that the head and body are different using the same developer console, I see you unexpected behavior was said.

Nowadays tags have been identified based on references and the browsers are & lt; Html & gt; & Lt; Title & gt; Title which violates many rules, try for yourself!

Hope that helps! :)


Comments