
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Building Javascript applications that run across multiple browser tabs can be tricky:
BrowserTab encapsulates all of this behavior into a simple API:
BrowserTab.hidden()
true when the current tab is hidden from the visitorBrowserTab.primary()
true when the current tab is the most-recently-used tabIn the browser, just include the module with <script src="browsertab.js"></script>
.
Then you should be able to use the global BrowserTab object:
if (BrowserTab.hidden()) {
// This tab is not visible, maybe you can stop requesting data from the server
}
if (BrowserTab.primary()) {
// This tab is primary, should be okay to trigger things like sounds from this one
}
You can also listen for changes to hidden/primary state:
BrowserTab.on("change:hidden", function() {
// This tab changed from visible to hidden, or vice-versa.
});
BrowserTab.on("change:primary", function() {
// This tab changed from primary to non-primary, or vice-versa.
});
You can use BrowserTab in node:
npm install browsertab
var BrowserTab = require("browsertab")
var tab = new BrowserTab({window: jsdom().createWindow()})
In general, you can inject all of the BrowserTab dependencies using the options:
var tab = new BrowserTab({
window: window, // override window (helpful when mocking in unit tests)
document: document, // override document (helpful when mocking in unit tests)
localStorage: localStorage, // override localStorage (helpful when mocking in unit tests)
storageNamespace: "_BrowserTabStorageNamespace" // change storage namespace for coordinating "primary" tab
})
Found a bug? Have a new idea? Fork away and send us a pull request! Or call us, maybe?
FAQs
Track which tabs are visible and most-recently-used.
The npm package browsertab receives a total of 0 weekly downloads. As such, browsertab popularity was classified as not popular.
We found that browsertab 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
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.