javascript shim && polyfill 介绍
2018-04-06 本文已影响0人
飞鱼_JS
shim
- 一个shim就是一个库,它将一个新的API引入到一个旧的环境中,而且仅靠旧环境中已有的手段实现,Shim有时候也称为shiv,比如著名的HTML5兼容库html5shiv
polyfill
- 一个polyfill是一段代码(或者插件),提供了那些开发者们希望浏览器原生提供支持的功能。
- 一个polyfill就是一个用在浏览器API上的shim,我们通常的做法是先检查当前浏览器是否支持某个API,如果不支持的话就加载对应的polyfill,然后新旧浏览器就都可以使用这个API了