Badass JavaScript

A showcase of awesome JavaScript that pushes the boundaries of what's possible on the web, by @devongovett.

Shumway: Mozilla’s Flash VM and Runtime in JavaScript

June 18th 2012

Mozilla Labs has been working on some pretty interesting projects recently, including PDF.js their PDF renderer in JavaScript, and now Shumway, their “experiment that explores building a faithful and efficient renderer for the SWF file format without native code assistance.”

We have seen other experiments of this type including Tobias Schneider’s Gordon project a couple years ago.  Shumway takes this a step further, however, and supports some of the newer and more advanced interactive features of Flash, including two ActionScript VMs written in JavaScript.

All of Shumway’s rendering occurs using the HTML5 canvas element, as you might expect. And it turns out, once again, that JavaScript is actually fast enough to make this work well.  There are two demos available online, a racing game and a SWF inspector where you can choose any SWF file and Shumway will play it.  The racing game is particularly interesting, as it shows that the performance of the ActionScript and graphics engines are fast enough to run real world Flash applications.  JavaScript performance is getting really good these days, and many people still underestimate it.

I’m sure there is still a lot of work left for Shumway, but it has come a long way already.  I waited until there was a nice demo to show you to write about it, but if you’re interested in the source code make sure to check it out on Github.  Nice work, Mozilla Labs!  Can’t wait to see more.