Home

Awesome

timeweb

timeweb is a JavaScript library that overwrites native time handling in a web page, creating a virtual timeline independent of real time.

<a name="scope" href="#scope">#</a> Scope

timeweb overwrites these time-related features in web pages:

<a name="limitations" href="#limitations">#</a> timeweb Limitations

These time-related features are known not to work:

Additionally timeweb is limited by what can be overwritten in browser by JavaScript and not everything may work as intended. Please file an issue if you think something should work.

Read Me Contents

<a name="use" href="#use">#</a> Script Use

<a name="how-it-works" href="#how-it-works">#</a> How it works

For JavaScript functions, timeweb overwrites a page's native time-handling functions and objects (new Date(), Date.now, performance.now, requestAnimationFrame, setTimeout, setInterval, cancelAnimationFrame, clearTimeout, and clearInterval) to custom ones that use a virtual timeline, which can be stepped through programmatically.

For videos/SVGs, timeweb detects when video and svg elements are created or added to the page by using a mutation observer and overwriting document.createElement. It pauses those elements and seeks when needed.

For animations available through the Web Animations API(CSS Transitions, CSS Animations, and element.animate()), timeweb detects new animations through transitionstart, animationrun listeners, document.getAnimations, and overwriting Element.prototype.animate. It pauses the animations and seeks when needed.

This work was inspired by a talk by Noah Veltman, who described altering a document's Date.now and performance.now functions to refer to a virtual time and using puppeteer to change that virtual time and take snapshots.