pollyfill definition

Hey, what exactly is pollyfill? I've heard it mentioned a lot. I looked into it and it said it's adding functionality for browsers that don't support certain features etc. Is there more to it? Thanks in advance.
7 Replies
ἔρως
ἔρως2w ago
polyfill is a way to re-implement functionality that the browser doesn't support because it's newer than it's existence for example, a polyfill for .forEach or .map was very common when those methods were released
Choo♚𝕂𝕚𝕟𝕘
Many new language features give an easier more concise way to do things that were already possible before. The polyfill is the harder more verbose version made available in situations in which the new language feature is unavailable.
snxxwyy
snxxwyyOP2w ago
Ahh okay I see. So it’s essentially an older version of a new feature that you’d also implement along side the new feature to make sure that the functionality you’re trying to implement works across different browser versions?
Jochem
Jochem2w ago
They check if the feature is supported and then implement it in Javascript rather than the engine if it isn't. You as a user just call .map and don't worry about the details
ἔρως
ἔρως2w ago
yup, you dont have to change your code at all tomorrow's features on yesterday's engine not everything can be polyfilled, like syntax changes those can be transpiled for old versions for example, old browsers that dont support classes can have classes by running your code through babel that's not what a polyfill is: a polyfill doesnt require you to change the code at all
Jochem
Jochem2w ago
yeah, so you can't polyfill the nullish coalescing assignment operator ??= in old browsers, but you can polyfill .map or .querySelector (though you're talking very old browsers if you're polyfilling querySelector)
ἔρως
ἔρως2w ago
you can also polyfill promises or some events once, i implemented a polyfill for the exclusive accordion functionality using <details> but one thing you cant polyfill (without plugins) is serial communication
Want results from more Discord servers?
Add your server