简体   繁体   English

ie metatag触发边缘模式的最佳位置

[英]Best position for ie metatag triggering edge mode

There is advice that says the meta-tag declaring encoding should be as early as possible, preferably first in the head like so: 有建议说元标记声明编码应该尽可能早,最好先在头部像这样:

<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 discernible effect where in this flow I put 现在我想知道它在这个流程中是否有任何可辨别的效果

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

Possible problems/issues that I've not read any research about: 我没有读过任何研究的可能的问题/问题:

  • Performance 性能
  • Flash of old-layout-engine layout before switching... 切换前的旧布局引擎布局的Flash ...

Instinct tells me to put the meta-tag as early as possible, but are there any hard evidence? Instinct告诉我尽早放置元标记,但有没有确凿证据?

Not a hard evidence, but a theory of mine: since the Document does not yet have a body, no paints or flows have been made after the head element is finished. 不是一个确凿的证据,而是一个我的理论:由于文件还没有一个主体,头元素完成后没有任何油漆或流动。 When the body element is parsed and painting begins, the X-UA-Compatible directives should have been dealt with already. 解析body元素并开始绘制时,应该已经处理了X-UA-Compatible指令。 So when it comes Stylesheets, it should not matter. 因此,当Stylesheets出现时,它应该无关紧要。

Scripts, however, are blocking parsing and will be executed when they shows up, unless they use the defer attribute and the IE version supports it. 但是,脚本阻止解析并在它们出现时执行,除非它们使用defer属性并且IE版本支持它。

One could argue that delayed callbacks gets the change, though; 有人可能会说延迟回调会得到改变; I have onContentLoaded callbacks, window.onload callbacks and callbacks wrapped with setTimeout in mind. 我有onContentLoaded回调, window.onload回调以及用setTimeout包装的回调。 So when it comes to script, the position of X-UA-Compatible meta matters. 因此,当涉及到脚本时, X-UA-Compatible元的位置很重要。 It would be really interesting to do some testing with this. 用这个做一些测试真的很有意思。

If scripts are placed at the bottom of the body element, like Souders recommends, it should not be a problem though. 如果脚本放在body元素的底部,就像Souders建议的那样,它应该不是问题。

At the end of the day, the most bulletproof solution is to skip meta elements and instead use HTTP headers. 在一天结束时,最灵活的解决方案是跳过元元素,而是使用HTTP标头。 That is what I would do. 这就是我要做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM