/ˈpɒl.i.fɪl/
一段代码(通常是 JavaScript),用于在不支持某项功能的旧版浏览器或环境中模拟实现该功能,使其表现得与原生支持一致。
I added a polyfill so the website works on older browsers.
我添加了一个 polyfill,这样网站就能在旧版浏览器上正常运行了。
Before deploying the application, the team included several polyfills to ensure backward compatibility with Internet Explorer, which lacked support for modern JavaScript features like Promise and fetch.
在部署应用之前,团队引入了多个 polyfill,以确保与 Internet Explorer 的向后兼容性,因为该浏览器不支持 Promise 和 fetch 等现代 JavaScript 功能。
该词由 Remy Sharp 于 2010 年左右创造。poly 来自希腊语,意为"多的",而 fill 意为"填充"。灵感来源于英国的一种墙面填充剂品牌 Polyfilla(类似腻子),用来填补墙上的裂缝和孔洞。Remy Sharp 借用这个比喻,表示 polyfill 就像是用代码去"填补"浏览器功能上的空缺,使旧环境也能使用新特性。