Platform.js v1.3.5
A platform detection library that works on nearly all JavaScript platforms.
Disclaimer
Platform.js is for informational purposes only & not intended as a substitution for feature detection/inference checks.
Documentation
- doc/README.md
- wiki/Changelog
- wiki/Roadmap
- platform.js demo (See also whatsmyua.info for comparisons between platform.js and other platform detection libraries)
Installation
In a browser:
In an AMD loader:
;
Using npm:
$ npm i --save platform
In Node.js:
var platform = ;
Usage example:
// on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit editionplatformname; // 'IE'platformversion; // '10.0'platformlayout; // 'Trident'platformos; // 'Windows Server 2008 R2 / 7 x64'platformdescription; // 'IE 10.0 x86 (platform preview; running in IE 7 mode) on Windows Server 2008 R2 / 7 x64' // or on an iPadplatformname; // 'Safari'platformversion; // '5.1'platformproduct; // 'iPad'platformmanufacturer; // 'Apple'platformlayout; // 'WebKit'platformos; // 'iOS 5.0'platformdescription; // 'Safari 5.1 on Apple iPad (iOS 5.0)' // or parsing a given UA stringvar info = platform;infoname; // 'Opera'infoversion; // '11.52'infolayout; // 'Presto'infoos; // 'Mac OS X 10.7.2'infodescription; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'
Support
Tested in Chrome 82-83, Firefox 77-78, IE 11, Edge 82-83, Safari 12-13, Node.js 4-14, & PhantomJS 2.1.1.
BestieJS
Platform.js is part of the BestieJS “Best in Class” module collection. This means we promote solid browser/environment support, ES5+ precedents, unit testing, & plenty of documentation.