In http://html5please.com the each features listed by saying use with Polyfill or Fallback. I was wondering what is the different both? kindly help me in understanding the different.
Thanks in advance.
If the feature exists in the browser, the polyfill lets the browser do its thing, if not, the polyfill steps in to plug the missing functionality. They fill in the holes of older browsers, the missing features we want to use today. It replicates a native API with non-native code. What Missing Features Are We Talking About?
When you can’t polyfill a feature, you have to transpile it. Transpiling (transforming + compiling) is the process of converting your newer code into an older code equivalent. You can’t use polyfills to “adapt” the new language syntax; in these cases, the best choice is to use a tool that converts your code.
So you can use a polyfill if your target browser did not implement the feature you need to use. A transpiler, on the other hand, is more complex and will let you use the new language syntax and transforming your source code. Thanks for reading me!
However, you can’t polyfill the syntax of JavaScript. While Babel will take your arrow functions and turn them into regular functions, a polyfill will add methods to the global scope and to native prototypes.
Polyfill replaces the feature with the same functionality but implemented with supported technologies, so you're still able to use the same API as in new browsers. For example, classList only supported starting from IE10, but you can add a script written in js that adds a classList object to any dom element so you don't need to rewrite your code to detect a browser or a feature.
Fallback usually replaces the feature with simplified functionality or third-party plugin or even error message. For example, if the browser does not support video tag, you can replace it with a flash plugin.
UPD: You can also check this question for more information.
Use with Polyfill means that there is some JavaScript code available to do more or less the same thing as the native browser feature.
Use with Fallback means that it isn't practical to emulate the feature using JavaScript, and you should provide some fallback so that the page still works on less capable browsers, albeit with reduced functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With