Wednesday, September 8, 2010: You Can Distort Time. At Least in JavaScript. « from the old blog archive »

Tested on Firefox. Untested on other browsers. :P

Couple of hours ago something crazy came to my head. I want to control the flow of time by manipulating the Date() constructor and see what's gonna happen.

So I wrote this code. This JavaScript code makes the Date() constructor slow down 4 times.

For example, if I inject the JavaScript at 12:00 PM, then wait 4 minutes, and check the current time, it will say 12:01 PM. You get the point.

The setInterval and setTimeout function is also modified to be slower.

As a live example, I have included the script on this page too. All animations on this page will be 4 times slower! Compare it with the home page!

You can also have the slow down bookmarklet.

Try it! Drag the bookmarklet to the bookmarks bar, and then go to some site with animation effects (for example, http://jquery.com/) and activate it. You will see that all the animations in the page will be 4x slower.

The bookmarklet will not work with some websites or JavaScript frameworks that keeps the original Date constructor and use it, but as far as I know, jQuery always use the Date constructor currently present in window.

This bookmarklet will not work with CSS transitions.

........................

I'll see if I can do something fun with this.