HTML5 Shiv 和 Modernizr

HTML5 Shiv and Modernizr

我正在使用 Modernizr,我下载时使用 "HTML5Shiv" 我选中了复选框。

但我的问题是...我是否必须像这样放置条件:

<!--[if lt IE 9]>
include html5shiv from Modernizr
<![endif]-->

如果答案是肯定的,我必须在其中包含什么脚本?

不,html5shiv 将在您的 modernizr 文件的源代码中。您不需要任何条件注释。

您不需要条件评论; html5shiv 脚本会自动添加到 Modernizr 源代码中。

According to the docs:

As of Modernizr 1.5, this script is identical to what is used in the popular html5shim/html5shiv library. Both also enable printability of HTML5 elements in IE6-8, though you might want to try out the performance hit if you have over 100kb of CSS.

但是,如果您想利用 Modernizr 的 shiv,则需要将脚本放在 <head> 标签中:

The reason we recommend placing Modernizr in the head is two-fold: the HTML5 Shiv (that enables HTML5 elements in IE) must execute before the<body>, and if you’re using any of the CSS classes that Modernizr adds, you’ll want to prevent a FOUC.