DEV Community

Discussion on: Differential Serving

Collapse
 
thejohnstew profile image
John Stewart

Curious to know why user agent agent detection is a problem?

It seems there is a widely used and well supported project within the node ecosystem to do this and to do it well.

npmjs.com/package/useragent

I think it is ready for mainstream. It's a matter of understanding what browsers your customers are using and trying to ship JS to specific browsers. As far a performance goes, you get some benefits of sending less code on newer browsers and the newer browsers are optimized for the new JS as well. And on the older browsers they are getting the same JS they would have got anyways.

I agree the double download could be a nonstarter but with user agent sniffing the worst case there is the current situation.

Collapse
 
philnash profile image
Phil Nash

I've never been a fan of user agent sniffing because of the unpredictability of the user agents, I prefer feature detection, which was the initial intention of the two script tags.

I like that there's a community supported project in Node, but that doesn't sort things for other language ecosystems or staticly rendered sites either. I admit, that when the worst case is the fallback to ES5 transpiled code, it's not the worst thing and the potential benefits probably outweigh my concern.