The best position, for example, for the cross effect mode of the metatag

There is advice saying that the meta tag declaring the encoding should be as early as possible, preferably first in the head:

<head> <meta charset="utf-" /><!-- Yes I like XHTML syntax, get over it --> <title></title> <!-- The usual suspects --> </head> 

Now I wonder if it has any noticeable effect , where in this thread I put

 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 

Possible problems / problems that I have not read any research about:

  • Performance
  • Flash layout old layout before switching ...

My instinct tells me to put the meta tag as early as possible, but is there any convincing evidence?

+4
source share
1 answer

Not convincing proof, but my theory: since the Document does not yet have a body, after the head element is finished, no paints or streams were made. When the body element is disassembled and drawing begins, the X-UA-Compatible directives should have been considered already. Therefore, when it comes to styles, it does not matter.

The scripts, however, block parsing and will run when they appear, unless they use the defer attribute, and the IE version supports it.

It can be argued that deferred callbacks receive a change; I have onContentLoaded callbacks, window.onload callbacks and callbacks wrapped in setTimeout . Therefore, when it comes to script, the position of X-UA-Compatible matters. It would be really interesting to do some testing with this.

If scripts are placed at the bottom of the body element, as Souders recommends, this should not be a problem.

At the end of the day, the most bulletproof solution is to skip the meta elements and use HTTP headers instead. This is what I would do.

+1
source

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


All Articles