How is the code * between * the end of the HEAD tag and before the BODY tag handled?

I read that this is bad for this, and beyond the specification, but I have an error that is somewhat intermittent and may be related. I just want to know if the general consensus is "to burn this code with napalm" or "it works in these limited conditions."

I found in a very complex code base tags <script>that are downloaded from external sources (javascript and jquery), and embedded scripts after </head>and before <body>. Most of them are code that needs to be downloaded after the form is fully loaded.

Before making any changes to include the code at the bottom of the Head tag, I would like to understand what is happening right now for clients who run this code (the goal is not to disrupt the current user), Will these be loaded scripts before the page will be displayed or after? What is the actual state of this code of an unearthly person, which should not be in the first place?

Thank!

+3
source share
2 answers

Content between the </head>end tag and the <body>start tag is inserted just before the start of the tag <body>, unless it is an element that does not belong to the body, in which case it will be inserted at the end of the head.

, script, , ; script , " ", .

. 8.2.5.4.4 " " , 8.2.5.4.6 " " 8.2.5.4.7 " " W3C HTML . , , - , , , .

+4

, , . , , .

: </head> <body>, "" ". , , , :

  • , : "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "template", ""
    • .
    • node, head .
    • , " " .
    • node, . ( node.)
    • .

, :

  • , . .: -)
  • , , script, head.

:

" ", :

  • , U + 0009 , "LF" (U + 000A), "FF" (U + 000C), "CR" (U + 000D) U + 0020

    • .
    • .
  • DOCTYPE

    • . .
  • , "html"

    • , " " .
  • , ""

    • HTML .
    • frameset-ok " ".
    • " " .
  • , "frameset"

    • HTML .
    • " frameset".
  • , : "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "", ""

    • .
    • node, head .
    • , " " .
    • node, . ( node.)
    • .
  • , ""

    • , " " .
  • , : "", "html", "br"

    • "- " .
  • , "head"

    • . .
  • -

    • HTML "body" .
    • " " .
    • .
+7

Source: https://habr.com/ru/post/1679342/


All Articles