polyfill.io trial

Polyfill and standard API can provide the same functionality for older browsers. For example, you want IE browser realize Promise and fetch function, you need to manually introduced es6-promise, whatwg-fetch. And by Polyfill.io, you only need to introduce a JS file.

<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>

Polyfill.io request header by analyzing information UserAgent automatically load the required browser polyfills. Polyfill.io have a default list of features, including the most common polyfills: document.querySelector, Element.classList, ES5 new Array methods, Date.now, ES6 in Object.assign, Promise and so on.

<!DOCTYPE html>
<html lang="en">
<head> 
<meta charset="UTF-8"> 
<title>Document</title>     
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?callback=main" async defer></script> 
<script>  
function main(){            
  var node=document.createElement("script");
  node.src="index.js";             
  document.body.appendChild(node);   
}     
</script> 
</head>
<body> 
</body> 
</html>

Reference link: https: //www.jianshu.com/p/3e0bf9a414e3

Guess you like

Origin www.cnblogs.com/pengxiangchong/p/11647128.html