A platform detection library.

Overview

Platform.js v1.3.6

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

Installation

In a browser:

<script src="platform.js"></script>

In an AMD loader:

require(['platform'], function(platform) {/*…*/});

Using npm:

$ npm i --save platform

In Node.js:

var platform = require('platform');

Usage example:

// on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit edition
platform.name; // 'IE'
platform.version; // '10.0'
platform.layout; // 'Trident'
platform.os; // 'Windows Server 2008 R2 / 7 x64'
platform.description; // 'IE 10.0 x86 (platform preview; running in IE 7 mode) on Windows Server 2008 R2 / 7 x64'

// or on an iPad
platform.name; // 'Safari'
platform.version; // '5.1'
platform.product; // 'iPad'
platform.manufacturer; // 'Apple'
platform.layout; // 'WebKit'
platform.os; // 'iOS 5.0'
platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)'

// or parsing a given UA string
var info = platform.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7.2; en; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 11.52');
info.name; // 'Opera'
info.version; // '11.52'
info.layout; // 'Presto'
info.os; // 'Mac OS X 10.7.2'
info.description; // '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.

Comments
  • Missing browsers

    Missing browsers

    PaleMoon Waterfox SamsungBrowser AOL UCBrowser (popular in Japan) YaBrowser (popular in Russia) Mobile Safari under Facebook (... FBAN and FBSV) Tesla (QtCarBrowser)

    Missing OS

    SCO_VS OpenBSD Tesla (Linux variant)

    If you want to add these do you need me to post the user-agents?

    enhancement 
    opened by jbardu 14
  • Incorrect browser Architecture.

    Incorrect browser Architecture.

    Incorrect browser Architecture. Test reports:

    Testing in Chrome 38.0.2100.0 32-bit on Windows 8 64-bit
    

    But test was actually tested on:

    Version 38.0.2100.0 canary (64-bit)
    

    As you can see, the version number is correct, but it states that it is 32-bit chrome, when it is 64-bit. Obviously the OS is correctly reporting 64-bit. I can confirm that the Browser is running in 64-bit mode too.

    window.navigator.userAgent:

    Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2
    

    I originally reported this on mathiasbynens/jsperf.com#183 and they directed me to here.

    bug 
    opened by WORMSS 10
  • Documentation of most common values for platform.os.family

    Documentation of most common values for platform.os.family

    Thanks for platform.js. Are the most common values for platform.os.family listed in the docs? I was unable to find if it is there, and in that case I'm sorry for opening this issue. If it isn't in the docs, I think this would be a useful addition.

    UPDATE 27th May 2014 I'll keep this table updated as new ones are added. Please go to http://jsfiddle.net/bGyNa/4/embedded/result/ to contribute your platform.os.family value if its not yet mentioned in the table:

    | platform.os.family | | --- | | OS X | | Android | | iOS |

    Table last updated: 27th May 2014 platform.js version 1.1.0

    documentation 
    opened by eliotsykes 10
  • Platform.js TypeError: Attempted to assign to readonly property. & Error: Assertion failed

    Platform.js TypeError: Attempted to assign to readonly property. & Error: Assertion failed

    We're experiencing the following problems with Platform.js

    • TypeError: Attempted to assign to readonly property.
    • Error: Assertion failed

    On the following lines: setting___remsis_admin

    Any suggestions? This code is 100% default.

    invalid 
    opened by DelawareConsulting 8
  • Fixing detection of IE 11 masking as Firefox

    Fixing detection of IE 11 masking as Firefox

    I got the user agent from a IE11 on windows 7 vm from here: http://www.modern.ie/en-us/virtualization-tools It was being detected as firefox, this corrects that.

    enhancement 
    opened by ibash 8
  • Add support for IE Tech Preview.

    Add support for IE Tech Preview.

    IE 11's UA is:

    Mozilla/5.0 (Windows NT 6.4; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; InfoPath.3; rv:11.0) like Gecko
    

    and IE Tech Preview is:

    Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Edge/12.0
    

    Because the Tech Preview is so similar to Chrome, sites like jsPerf and Browserscope are reporting it as Chrome 36.

    enhancement 
    opened by jdalton 7
  • Errors in FireFox Aurora & FF fork

    Errors in FireFox Aurora & FF fork

    (Outdated) FireFox Aurora "ua": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0" but

    "prerelease": null,`
    "manufacturer": null,
    

    FireFox fork PaleMoon "ua": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:24.0) Gecko/20140316 Firefox/24.0 PaleMoon/24.4.1" but

    "name": null,
    "version": null,
    "manufacturer": null,
    "product": null,
    
    enhancement wontfix 
    opened by tomByrer 7
  • Incorrect Chrome version detection

    Incorrect Chrome version detection

    The version of Chrome is incorrect.

    E.g Run the test by adding following user agent node to test.js - 'Chrome 40.0.2214.89 on (Android 5.1.1)': { 'ua': 'Mozilla/5.0 (Linux; Android 5.1.1; SGP521 Build/23.4.A.0.546) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 Safari/537.36', 'layout': 'Blink', 'name': 'Chrome', 'os': 'Android 5.1.1, 'version': '40.0.2214.89' } Result: Detects version as 4.0.0 instead of 40.0.2214.89. Screeshot of the test output: screen shot 2015-07-24 at 11 55 58 am

    change 
    opened by ashwini-desai 6
  • Create a site?

    Create a site?

    @jdalton I've worked on a basic site to showcase platform.js, available at http://d10.github.io/platform-demo/. Do you think we should have a site like Benchmark.js's?

    enhancement 
    opened by bnjmnt4n 6
  • Chrome on iOS gets reported as Safari

    Chrome on iOS gets reported as Safari

    User agent string for Chrome on iOS6 "Mozilla/5.0 (iPad; CPU OS 6_1_2 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/32.0.1700.20 Mobile/10B146 Safari/8536.25"

    User agent string for Safari on iOS6 "Mozilla/5.0 (iPad; CPU OS 6_1_2 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B146 Safari/8536.25"

    We are using version 1.0.0 of platform.js and chrome on iOS gets reported as safari with version set to 5+.

    From Google developers documentation, it seems like the "CriOS/" part of the user-agent string needs to be used to detect chrome. Here is the link - https://developers.google.com/chrome/mobile/docs/user-agent

    Thanks, Naveen

    invalid 
    opened by nramaiah 6
  • New release with security fixes

    New release with security fixes

    Hello would it be possible to do a release with this commit https://github.com/bestiejs/platform.js/commit/f86e37437c155fb39253e5bcaa99e8cd265d5a12 that would be great! ;) would fix some secutiry warnings in our repo

    Thank you!

    question 
    opened by joaogarin 5
  • Why v1.3.6 is parsing Edge as

    Why v1.3.6 is parsing Edge as "Microsoft Edge" instead of "Chrome"

    On v1.3.5 UA string of Microsoft edge was parsed as "Chrome". But in v1.3.6 it's changed to "Microsoft Edge". Is this a bug or intentional ?

    Also, Brave browser is being parsed as "Chrome".

    opened by adil62 0
  • Can we detect Apple M1/ARM machines?

    Can we detect Apple M1/ARM machines?

    We use platform.js on a website to show the right "download button" for our application (GIMP). For instance, Windows people would get the Windows installer button, macOS people would get a DMG download and Linux people would get a Flatpak link.

    It's of course only a default and there are links to show and get downloads for other platforms, but it has been very nice so far to be able to guess the expected binary to show (instead of 10 buttons to choose from) at first.

    Lately we are getting a DMG package for Apple M1 (arm 64-bit Apple machines). We are trying to find out how to detect this. Does the current version of platform.js provide an info which is reliable enough to guess which architecture variant of macOS one is using?

    opened by Jehan 0
  • Detect Windows 11 (User-Agent Client Hints)

    Detect Windows 11 (User-Agent Client Hints)

    Hi. This library is extremely helpful!

    Recently we came across the issue, that browsers don't report Windows 11 in the user agent string anymore.

    A research revealed that there's a shift to new "User-Agent Client Hints" [1] and Windows made it even official [2] and forces developers to use this feature as the only way to detect Windows 11 (at least in Edge).

    It would be awesome to see this feature also in platform.js.

    Thanks in advance!

    [1] https://web.dev/migrate-to-ua-ch/ [2] https://docs.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11

    opened by opusonline 0
  • Cannot read property '0' of null #109 -- not fixed

    Cannot read property '0' of null #109 -- not fixed

    I am using version 1.3.3 and still encountering the same problem raised in this issue.

    Screen Shot 2021-11-29 at 3 56 24 PM

    As the screenshot below demonstrates, data.version is undefined in this case.

    Screen Shot 2021-11-29 at 3 50 20 PM

    The following change is working for me.

    if (data.version)
      version = /[\d.]+/.exec(data.version)[0];
    else 
      version = /[\d.]+/.exec(data.env.VERSION)[0];
    

    I'm not sure exactly why this is occurring, but the issue seems to arise when I install [email protected] or [email protected] in my project, not meteor as originally reported.

    My setup info below - happy to provide more details or a complete reproduction if helpful. Angular CLI: 8.3.26 Node: 16.13.0 OS: darwin x64 Angular: 8.2.14

    opened by JulianneZech 0
Owner
BestieJS Modules
BestieJS Modules
🐡 A simple open source phishing platform for red teams

?? A simple open source phishing platform for red teams

Christos Kaltsas 5 Apr 14, 2022
The perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML.

List.js Perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on

Jonny Strömberg 10.9k Jan 1, 2023
A high-performance, dependency-free library for animated filtering, sorting, insertion, removal and more

MixItUp 3 MixItUp is a high-performance, dependency-free library for animated DOM manipulation, giving you the power to filter, sort, add and remove D

Patrick Kunka 4.5k Dec 24, 2022
Drag and drop library for two-dimensional, resizable and responsive lists

GridList Drag and drop library for a two-dimensional resizable and responsive list of items Demo: http://hootsuite.github.io/grid/ The GridList librar

Hootsuite 3.6k Dec 14, 2022
JavaScript Survey and Form Library

SurveyJS is a JavaScript Survey and Form Library. SurveyJS is a modern way to add surveys and forms to your website. It has versions for Angular, jQue

SurveyJS 3.5k Jan 1, 2023
Extensive math expression evaluator library for JavaScript and Node.js

?? Homepage Fcaljs is an extensive math expression evaluator library for JavaScript and Node.js. Using fcal, you can perform basic arithmetic, percent

Santhosh Kumar 93 Dec 19, 2022
Browser fingerprinting library with the highest accuracy and stability.

FingerprintJS is a browser fingerprinting library that queries browser attributes and computes a hashed visitor identifier from them. Unlike cookies a

FingerprintJS 18.1k Dec 31, 2022
A benchmarking library. As used on jsPerf.com.

Benchmark.js v2.1.4 A robust benchmarking library that supports high-resolution timers & returns statistically significant results. As seen on jsPerf.

BestieJS Modules 5.3k Dec 28, 2022
autoNumeric is a standalone library that provides live as-you-type formatting for international numbers and currencies.

What is autoNumeric? autoNumeric is a standalone Javascript library that provides live as-you-type formatting for international numbers and currencies

AutoNumeric 1.7k Dec 16, 2022
A wrapper library for Jitsi Meet that adds audio spatialization, to be able to create virtual meeting rooms.

A wrapper library for Jitsi Meet that adds audio spatialization, to be able to create virtual meeting rooms.

Sean T. McBeth 1.1k Dec 27, 2022
Solid.js library adding signaling to built-in non-primitives

This package provides signaled versions of Javascript's built-in objects. Thanks to it, all theirs properties will be automatically tracked while using standard API.

Maciej Kwaśniak 40 Dec 29, 2022
This library was designed to be used in SPA framework wrappers for the FingerprintJS Pro Javascript Agent

Framework-agnostic SPA service wrapper. Use it to build a FingerprintJS Pro wrapper for your favorite framework.

FingerprintJS 12 Sep 3, 2022
ChelseaJS - a Javascript library for creative, generative Coding

ChelseaJS is a Javascript library for creative, generative Coding. It's simple and intuitive syntax makes it easy for everyone (including non-coders)

Prakrisht Dahiya 26 Oct 6, 2022
Estrela - a JavaScript library for building reactive web components inspired by lit

Estrela ⭐ Full Reactive Web Components Estrela is a JavaScript library for building reactive web components inspired by lit. Just like Lit, Estrela is

null 50 Oct 31, 2022
A library for prototyping realtime hand detection (bounding box), directly in the browser.

Handtrack.js View a live demo in your browser here. Handtrack.js is a library for prototyping realtime hand detection (bounding box), directly in the

Victor Dibia 2.7k Jan 3, 2023
JavaScript syntax highlighter with language auto-detection and zero dependencies.

Highlight.js Highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It can work with pretty muc

highlight.js 20.8k Jan 5, 2023
Magic number detection for JavaScript

Magic number detection for javascript. Let Buddy sniff out the unnamed numerical constants in your code. Overview What are magic numbers? Installation

Daniel St. Jules 827 Dec 24, 2022
JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js

face-api.js JavaScript face recognition API for the browser and nodejs implemented on top of tensorflow.js core (tensorflow/tfjs-core) Click me for Li

Vincent Mühler 14.6k Jan 2, 2023
Defacement detection with deep learning

In0ri is a defacement detection system utilizing a image-classification convolutional neural network. Introduction When monitoring a website, In0ri wi

Just4Fun Security 47 Nov 30, 2022
🛤 Detection of elements in viewport & smooth scrolling with parallax.

Locomotive Scroll Detection of elements in viewport & smooth scrolling with parallax effects. Installation ⚠️ Scroll-hijacking is a controversial prac

Locomotive 5.9k Dec 31, 2022