📜  shim 和 polyfill 有什么区别?

📅  最后修改于: 2022-05-13 01:56:20.561000             🧑  作者: Mango

shim 和 polyfill 有什么区别?

Shim :JavaScript 语言中的 Shim 库是实际上阻塞 API(应用程序编程接口)调用并修改传递的参数、处理操作本身或有时将操作重定向到其他地方的概念。 Shim 还可用于在为其开发的各种软件平台上执行程序。 Shim 无法在 API 调用中添加缺少的实现。

Polyfill: Polyfill 或 Polyfilling 是 Shim 或 Shimming 的下一个版本或更高版本。 Polyfill 是在 API 调用中实现丢失功能的概念,其中 Shim 无法实现丢失的功能。 Polyfill 是一段代码或插件,它提供了您作为开发人员期望 Web 浏览器原生提供的技术。 Polyfill 添加了具有现代 HTML5/CSS3 实现的旧版浏览器。

Shim 和 Polyfill 之间的区别

Shim

Polyfill

Shim is a simple library that brings a newer API to an older platform environment.Ployfill is the Shim for a web browser API which checks if the browser has the support to an API
Shim code could add (i.e. JavaScript) that would fix some functionality, but it would most often have its own API.Polyfill is something you could drop in (i.e. JavaScript) and it would silently work to imitate existing browser APIs that are otherwise unsupported.
Shim doesn’t install the missing features in an API call.Polyfill installs its own implementation if the features are missing.
Shim can only correct the behavior of code that already exists,Polyfill implements a feature on web browsers that do not support the feature whether it is existing or not.