Friday, June 22, 2007

FireBox: Put The Fox In The Box

I've finally found the right development environment for myself for writing and debugging Web Applications that use JavaScript to implement client-side interaction. It turns out that it wasn't just me who found the thought of programming inside the Web browser a painful experience --- pleasant though the final end-user interaction that those results deliver might be for the final user. I discovered MozRepl --- a read-eval-print loop for Firefox. MozRepl is a Firefox extension that allows you to open a connection to a running Firefox session and gain access to a JavaScript interpreter context that can access all aspects of the Firefox runtime.

This is quite neat, I can now use the power of Emacs to write and debug end-user JavaScript applications. But wait, there is more. So in general, as someone who doesn't need to suffer from the hit on cycles and memory that running an X environment involves, I usually dont start GDM --- the graphical desktop --- on my Linux box. Believe me, running just at the console, especially with the LCD turned off makes my laptop run a lot longer. So challenge: How do you take the fox's head off Firefox? How do you run a headless Firefox?

Turns out that the original X Windows developers didn't always have access to all the displays that they were developing X applications for --- so they created XVFB --- the X Virtual Frame Buffer server. Like all good things in the Open Source world, XVFB continues to survive --- even though today, X developers hardly if ever resort to XVFB. But in the fine UNIX tradition of Get out of my way or I'll turn you into a shell script XVFB also turns out to be just what I needed in order to run FireFox as a headless application.

So in summary: I'm typing this blog on the shuttle bus riding home, with the monitor turned off, and Firefox running headless as I debug some of the code I've been writing. If you want to put the fox's head in a box yourself, here is a pointer to FireBox -- share and enjoy!