即使浏览器本身支持使用的功能,Webshim 是否会从 polyfill 加载所有功能?
如果答案是“是”,我敢肯定,这将对性能造成巨大影响。即使我们指定了我们在网页中使用的功能。
示例:webshims.polyfill('forms forms-ext');
如果答案是“否”,Webshim 是使用“yesNope.js”来加载 polyfill 还是使用任何其他方法来加载 polyfill 文件。
提前致谢。
它不使用 YepNope,而是(自定义构建)Modernizr,这是一个类似的特征检测库。检查http://afarkas.github.io/webshim/demos/#Customizing-modernizr和https://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