Live data from Hacker News

An easier way of using polyfills

hacks.mozilla.org

41–50 of 80 posts

Re: An easier way of using polyfills

#41
post #36
post #34

A brief introduction to "polyfilling" and what that means would be pertinent. I've never heard that term and have no idea what this is about, nor do I care.

As a graphics guy I thought they referred to the algorithms used to fill polygons, but it turns out that "polyfills" in web developer parlance are developer implementations of things that should be standard in the browser but aren't. E.g. maybe all browsers implement an array sorting function, except for Internet Explorer. So for IE clients you'd load a "polyfill", which would be JS code that implements array sorting…

>I'm really glad I'm not a JS developer

Yeah, because other languages don't all have their issues...

"as a graphic guy" implies strongly "C++". Hardly the pinnacle of language design...

Re: An easier way of using polyfills

#42

While a neat idea in theory, I have some qualms about this. User agent detection sounds great, until you have a user that spoofs their agent. I often do so for various reasons, and from time to time I forget to turn it off after I've finished what I was doing. If this service becomes common, then I will be given broken webpages seemingly at random. The other option, a polyfill covering specific features and served to…

>User agent detection sounds great, until you have a user that spoofs their agent.

Yeah, properly serving that 0.01% demographic would be hard...

/s

Re: An easier way of using polyfills

#43
post #39
post #34

A brief introduction to "polyfilling" and what that means would be pertinent. I've never heard that term and have no idea what this is about, nor do I care.

Well, if you never heard that term, and 1) you are a front-end JS developer, perhaps front-end JS development is not for you. 2) you aren't a front-end JS developer, then the post wasn't meant for you, so not much need to explain anything.

3) you were born knowing everything about your trade, so no point posting articles like these.

Re: An easier way of using polyfills

#44
So we've spent years shouting out the mantra "test for features, not browsers!" and now Mozilla, of all people, tell us that that was basically a bit impractical, and we should just go back to user-agent sniffing like we did 8-10 years ago?

Re: An easier way of using polyfills

#45
post #41
post #36

Earlier quoted context omitted.

As a graphics guy I thought they referred to the algorithms used to fill polygons, but it turns out that "polyfills" in web developer parlance are developer implementations of things that should be standard in the browser but aren't. E.g. maybe all browsers implement an array sorting function, except for Internet Explorer. So for IE clients you'd load a "polyfill", which would be JS code that implements array sorting…

> I'm really glad I'm not a JS developer Yeah, because other languages don't all have their issues... "as a graphic guy" implies strongly "C++". Hardly the pinnacle of language design...

Everyone picks their poison, why can't he be happy with the one he's picked?

Re: An easier way of using polyfills

#46
post #3

While a neat idea in theory, I have some qualms about this. User agent detection sounds great, until you have a user that spoofs their agent. I often do so for various reasons, and from time to time I forget to turn it off after I've finished what I was doing. If this service becomes common, then I will be given broken webpages seemingly at random. The other option, a polyfill covering specific features and served to…

>User agent detection sounds great, until you have a user that spoofs their agent. Do a significant percentage of users spoof their agent?

Most mobile browsers have a "request desktop site" feature, which I assume would involve spoofing the user agent to look like the desktop version.

Re: An easier way of using polyfills

#47
post #3

Earlier quoted context omitted.

>User agent detection sounds great, until you have a user that spoofs their agent. Do a significant percentage of users spoof their agent?

Most mobile browsers have a "request desktop site" feature, which I assume would involve spoofing the user agent to look like the desktop version.

It spoofs the platform, not the browser. Mobile Chrome/Safari should have feature parity with their computer cousins.

Re: An easier way of using polyfills

#48

Something is very wrong with how web developers think about threat models if they're so incredibly willing to load completely arbitrary code into their customer's applications from a source that isn't even remotely party to the vendor/customer relationship.

> Something is very wrong with how web developers think about threat models

Yes.

We have pretty much the same problem with the web, as we had with macro-viruses an office suites -- because we're solving the same problems in the same way, without learning from past mistakes. It might actually be worse, because if you tell people you don't run macros in untrusted office documents, most people will applaud you for being wise -- while if you say you use noscript people will dismiss you as a paranoid Luddite.

Runable code created by random people, from random sources, in one address space with access to all your user data -- what could go wrong?

Re: An easier way of using polyfills

#49

So we've spent years shouting out the mantra "test for features, not browsers!" and now Mozilla, of all people, tell us that that was basically a bit impractical, and we should just go back to user-agent sniffing like we did 8-10 years ago?

> and now Mozilla, of all people, tell us that that was basically a bit impractical

No. What Mozilla did was explain their reasons for doing so. So at the very least your comment should engage with their stated reasons in some detail. Otherwise it's hard for the rest of us to know whether you've got a valid objection or you just replied without really reading the original article.

Re: An easier way of using polyfills

#50

So we've spent years shouting out the mantra "test for features, not browsers!" and now Mozilla, of all people, tell us that that was basically a bit impractical, and we should just go back to user-agent sniffing like we did 8-10 years ago?

It looks like Mozilla is testing for virtually any web browser that is in use. That seems OK.

And, you can choose to do feature detection if you wish. Here's a quick example:

https://cdn.polyfill.io/v1/polyfill.js?features=Array.protot...

More information about that can be found here: https://cdn.polyfill.io/v1/docs/api

Post reply on HN