Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

background-timer

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

background-timer

Allows timeouts, intervals and animations to continue in background tabs.

  • 2.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

background-timer

DEPRECATED: Use silent-audio instead.

Allows timeouts, intervals and animations to continue in background tabs.

Timers will use regular methods when the tab is focused, and rely on timers within a small popup window when out of focus.

Why?

Chrome and Firefox throttle timers in background tabs to prevent abuse of resources. Unfortunately, well-behaving apps are sometimes broken by this policy. This provides a workaround, while still allowing the user to "opt-out" by closing the popup window.

Install

NPM:

npm install --save background-timer
const BackgroundTimer = require('background-timer')

Script:

<script src="dist/background-timer.js">
window.BackgroundTimer

Examples

  element.addEventListener('click', function () { // must be triggered by user event
    BackgroundTimer({global: true}) // override globals with this option
  })

  window.requestAnimationFrame(function () {}, 50)
  window.setInterval(function () {}, 50)
  window.setTimeout(function () {}, 50)
  
  window.cancelAnimationFrame(id)
  window.clearInterval(id)
  window.clearTimeout(id) 
  element.addEventListener('click', function () { // must be triggered by user event
    var backgroundTimer = new BackgroundTimer({global: false}) // it's cleaner to avoid globals
  })
  
  backgroundTimer.requestAnimationFrame(function () {}, 50)
  backgroundTimer.setInterval(function () {}, 50)
  backgroundTimer.setTimeout(function () {}, 50)
  
  backgroundTimer.cancelAnimationFrame(id)
  backgroundTimer.clearInterval(id)
  backgroundTimer.clearTimeout(id) 

FAQs

Package last updated on 03 Jan 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc