w3ctag / polyfills

Finding on polyfills
https://w3ctag.github.io/polyfills
18 stars 6 forks source link

Console warning for polyfills which have a native implementation necessary? #7

Closed cynthia closed 7 years ago

cynthia commented 7 years ago

When a full fledged native implementation is available, consider throwing a warning to the console to tell the site developer that they loaded a polyfill unnecessarily.

This warning would be implementation (e.g. browser version) specific, not entirely sure if it would be extremely beneficial to the developer.

There is a chance of it eventually being treated as noise, since if your ship targets include say, old versions of IE it's going to always show up in the log.

triblondon commented 7 years ago

@cynthia the point is that ideally, you have some form of feature detection logic that avoids serving those polyfills in the more recent browsers. I'm trying to solve the problem that, at the extreme, could mean megabytes of unnecessary code on the page. Take Intl, for example - the full polyfill with all locale date for all locales is over 20MB.

I agree that shipping this would be ludicrous but believe me I have polyfill.io server logs to prove people do it, and they even force us to serve it to browser that have it natively.

cynthia commented 7 years ago

I'll see if there is a better way to word this.

triblondon commented 7 years ago

Reviewed at F2F. @cynthia is not here but we agreed to reflect slightly more nuance in the wording. See https://github.com/w3ctag/polyfills/commit/fa5c8f4a3597f7c8a7457a4d33f14172ee41172c#diff-eacf331f0ffc35d4b482f1d15a887d3bL205

cynthia commented 7 years ago

Thanks for taking care of this. Looks good.