Webshim加载polyfill的所有功能?

时间:2014-03-28 15:30:17

标签: html5 polyfills webshim

即使所使用的功能在浏览器中本身支持,Webshim是否会加载polyfill中的所有功能?

如果答案是“是”,我相信,会有巨大的性能影响。即使我们指定了我们在网页中使用的功能。

示例:webshims.polyfill('forms forms-ext');

如果答案为“否”,则Webshim是否使用“yesNope.js”加载polyfill,或者使用任何其他方法加载polyfill文件。

提前致谢。

1 个答案:

答案 0 :(得分:1)

它不使用YepNope,而是(自定义构建)Modernizr,它是类似的特征检测库。 查看http://afarkas.github.io/webshim/demos/#Customizing-modernizrhttps://github.com/aFarkas/webshim/blob/gh-pages/js-webshim/dev/extras/modernizr-custom.js


polyfill方法仅添加传递给它的要素。见https://github.com/aFarkas/webshim/blob/gh-pages/js-webshim/dev/polyfiller.js


此外,每个polyfill必须有一个测试方法,基本上检查是否需要加载此polyfill。见http://afarkas.github.io/webshim/demos/#Customizing-extending