node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


L'user Agent

Pardon my French?

So I guess it's cute but most days I really don't give a about all this browser user agent detritus.

I just want to know which browser, which version, which operating system.


var ua = luserAgent(navigator.userAgent);
console.log("Hello "" "+ua.v+", on "+ua.os);
console.log(", world.");

You can drop the semi-colons or put them at the beginning of your lines or whatever if you're annoying like that, but honestly I'd rather you just use CoffeeScript at that point.

Eventually when I need it this will work as a CommonJS (node.js/CouchDB/browserify) module too. Right now I sometimes just copy/paste the code into my projects because that is awesome also*.


PLEASE: if you use this for browser detection you yes you Are The Reason we got this mess in the first place and I will cry. For you Argentina.


If all of the following are true:

  • you are not using jQuery, and
  • you have heard of Modernizr, and
  • you have filed a bug for the browser bug you are fighting

Then you may use the provided information to gaurd a carefully considered workaround for said browser bug.

Else you may only use this library for human consumption (e.g. reable browser info for statitics or exception logs)

Related work

c.f. and probably many many others but I got sick of not being able to find them /

Fine print

* so I really don't recommend just copy-pasting this into your project because my code here can only improve, but I also really don't care.

License: this but © me and I guess whoever else helped instead of that Sam dude. I don't even know that Sam dude.

Rhetorically asked questions

Dare I submit a pull request or even fork this you seem really rude.

And you hate jQuery? WHO HATES JQUERY IT IS THE WEB?!!!

But I love you.