Skip to content

esqew/timer.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

timer.js

A Web Worker timer designed for in-browser timing

Usage

See demo.html for a working demonstration.

Configuration

<div id="container">
    This script has been running for <span id="secondsLabel">0</span> seconds.
</div>
var worker;
if (window.Worker) {
    worker = new Worker('./path/to/timer.js');
    worker.onmessage = (e) => { // capture messages from the worker
        document.getElementById('secondsLabel').value = e.data.elapsedTime;
    }
}

Start the timer (action: 'start')

worker.postMessage({action: 'start'});

About

A Web Worker timing function

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published