Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Created April 9, 2012 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinrhode2/2342188 to your computer and use it in GitHub Desktop.
Save devinrhode2/2342188 to your computer and use it in GitHub Desktop.
UA-Sniffing-FTW
The internet abroad doesn't believe in UA sniffing. Maybe it
complicates things too much. I believe we can have a hybrid.
I thought hard about this. What the hell is so wrong about UA sniffing?
Ok, what if we don't have a user agent? I almost took the excuse:
"well, 90% of the time we'll have a UA (if not 100% of the time)
so, why worry about the 10%?"
EVERYBODY deserves the best experience their browser is capable of.
If they don't have a userAgent header, we can delay loading the majority
of resources for the page, and in javascript get the user-agent from navigator.userAgent
But I'm skipping over myself. The current argument against UA sniffing,
as I understand it, is that you make assumptions about what code will work.
This doesn't have to be, we can have a hybrid of the approach Modernizr takes.
Feature detection. It's the most reliable way to go.
**The proposal**
Run feature detects, and find out what shims/polyfills would be needed for various things.
Then, read navigator.userAgent, and send this shim list for this UserAgent
to a central database. Next time the server gets a request from this
exact UserAgent, it ALREADY knows what shims that browser needs, and
can also skip serving the feature detection tests.
Discuss on Hacker News: http://news.ycombinator.org/item?id=3816152 (or vote up)
Retweet and share if you support this idea! Holla @paul_irish and @modernizr if you feelz the need
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment