当前位置:网站首页>Shim and Polyfill in [concept collection]
Shim and Polyfill in [concept collection]
2022-07-03 06:53:00 【Alisone_ li】
shim
Is a small class library (lib), Provide independent API, To make up for the compatibility problem that people need to consider when using native languages in different environments .
such as : Use js Native Ajax In operation , Do you use XMLHttpRequest establish xhr object , But in IE8 On , You have to use ActiveXObject, To solve these compatibility problems , At the same time, simplify the operation ,jQuery There is .
jQuery The core idea is : write less,do more! therefore ,jQuery Can be seen as a shim.
polyfill
Is a small class library (lib), It's used to implement native that browsers don't support API Code for .
such as :IE9 The following is not supported html5 Some new labels , have access to HTML5 shim For compatibility ; Older browsers don't support ES6 as well as ES6+ Some new features of , have access to Babel To compile into ES5 Syntax compatible .
The code example is as follows :
if (!window.XMLHttpRequest) { window.XMLHttpRequest = function () { .... } }
Be careful
Native API Code for , It can be called polyfill Class library of , The solution must be in an incompatible environment , Redefinition JS Its own grammar , Will not redefine API.
shim and polyfill
1,shim and polyfill The purpose of is to solve browser compatibility , And provide convenient , This is also a class library (lib) One of the functions of ;
2,shim Contains polyfill, Wider scope , You can redefine API, and polyfill Relatively narrow ,API It must be JS standard ;
边栏推荐
猜你喜欢
vmware虚拟机C盘扩容
[classes and objects] explain classes and objects in simple terms
VMware virtual machine C disk expansion
DBNet:具有可微分二值化的实时场景文本检测
2022 - 06 - 23 vgmp - OSPF - Inter - Domain Security Policy - nat Policy (Update)
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
Summary of UI module design and practical application of agent mode
Chapter 8. MapReduce production experience
Realize PDF to picture conversion with C #
SSH link remote server and local display of remote graphical interface
随机推荐
instanceof
[leetcode] day93 - intersection of two arrays II
VMware virtual machine C disk expansion
Tool class static method calls @autowired injected service
Condition annotation in uni-app realizes cross segment compatibility, navigation jump and parameter transfer, component creation and use, and life cycle function
2022年华东师范大学计科考研复试机试题-详细题解
golang操作redis:写入、读取kv数据
Yolov3 learning notes
Software testing learning - day 3
New knowledge! The virtual machine network card causes your DNS resolution to slow down
vmware虚拟机C盘扩容
第8章、MapReduce 生产经验
利用C#实现Pdf转图片
Stream stream
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
Search engine Bing Bing advanced search skills
【LeetCode】Day93-两个数组的交集 II
如何迁移或复制VMware虚拟机系统
Interface test weather API
The dynamic analysis and calculation of expressions are really delicious for flee