
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
browser-platform
Advanced tools
This is a naive implementation of browser/platform detection in JavaScript.
It is exported as a CommonJS/Node-style module, the main exports is a function that is meant to be called by passing in the useragent.
// CommonJS/Node Import
var platform = require('browser-platform')(window.navigator.userAgent)
// Direct browser injection
var platform = getBrowserPlatform(window.navigator.userAgent);
document.documentElement.setAttribute('class', ['js'].concat(platform.classNames).join(' '))
When run client-side some features (namely touch) are detected from the environment if not easily determined from the useragent. Android and iOS assume touch.
You can use platform.classes.join(' ')
as CSS classes to be added to the html
element, which can help with platform specific quirks.
The base portable detection portion of the script originated with detectmobilebrowser.com's regular expression(s). The rest was written by me. This library is released under a permissive ISC license. It has been very useful for me, and at 2.3KB minified and gzipped, much smaller than most detection libraries.
FAQs
Naive browser/platform detection
The npm package browser-platform receives a total of 3 weekly downloads. As such, browser-platform popularity was classified as not popular.
We found that browser-platform demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.