Search code examples
javascripthtmlcsspolyfills

Relevance of polyfills and shims


So it's 2016. ECMAScript 2015 has been pretty much standardised. HTML5 and CSS3, although with a few minor quirks, is considerably usable.

However, tutorials nowadays still include polyfills and shims (good example being the Angular 2 quickstart). It seems illogical to me.

My inference of standardisation comes from CanIUse.com and the Kangax ES6 compatibility tables.

I would have agreed that Internet Explorer would be a main reason (darn you, MS) but I've checked the CanIUse usage-oriented tables and IE11 has only (as of 23 November, 2016) 3% usage in the world.

Then again, I've also checked ES6 support by browsers and browsers have 90% or above support (with Chrome leading with 97% and Safari 10 supposedly having 100% support).

So back to my question,

Why are polyfills still used if browsers have already caught up?

Cheers!


Solution

  • I think the one answer that can answer most questions surrounding older techniques in use by newer standard is because of legacy code and backwards compatibility. At the end of the day there will always be older code that needs to be ran by your browser, if we left support for polyfills off in ES6 then we would shatter a lot of websites. Beyond that, a lot of people decide (for whatever reason) not to update, things like polyfill can be used as legacy fall backs in the event a browser doesn't support a newer mechanic and instead requires something like polyfill to take it's place.