etienne-martin / device-detector-js

A precise user agent parser and device detector written in TypeScript
https://lx3rzx16x9.codesandbox.io/
GNU Lesser General Public License v3.0
475 stars 58 forks source link

Difference with ua-parser-js #116

Closed vvotekeb closed 3 years ago

vvotekeb commented 3 years ago

What benefits does this library provide in comparison with https://github.com/faisalman/ua-parser-js ?

etienne-martin commented 3 years ago

I haven't used ua-parser-js personnaly so I can't really compare but looking through their repo I'd say the main differences are:

TypeScript

device-detector-js has built-in types because it's written in typescript, no need to install an additional package. Type quality is usually better for packages written in TypeScript vs ones that maintain types separately like ua-parser-js.

Size

device-detector-js is a lot heavier 454.2kB vs 15.1kB for ua-parser-js. I think this is because device-detector-js is able to detect more devices/browsers/bots/apps and as a result comes with more regexes for detection which increases the size of the package.

Browser

device-detector-js is not recommended if you plan on using it in the browser, mostly because of its size.

Bots and crawlers

ua-parser-js doesn't seem to do bot/crawler detection, I may be wrong.

Tests

device-detector-js seems to have better test coverage based on the number of test fixtures, 130kb for ua-parser-js vs 5mb for device-detector-js.

Overall both package look pretty similar, I'd say if you plan to do user-agent detection in the browser, go with ua-parser-js because it's lighter in terms of package size (less bytes to send to your users).