Viewed 9188 times

There are lots of widgets provided by sites that are effectively bits of JavaScript that generate HTML through DOM manipulation or document.write(). Rather than slow the browser down even more with additional requests and trust yet another provider to be fast, reliable and not change the widget output, I want to execute* the JavaScript to generate the rendered HTML, and then save that HTML source.­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­

Things I've looked into that seem unworkable or way too difficult:

  1. The Links Browser (not lynx!)
  2. Headless use of Xvfb plus Firefox plus Greasemonkey (yikes)
  3. The all-Java browser toolkit Cobra (the best bet!)

Any ideas?

** Obviously you can't really execute the JavaScript completely, as it doesn't necessarily have an exit path, but you get the idea.

3 answers given for "Executing JavaScript to Render HTML for Server-Side Caching"

Accepted Solution

Wikipedia's mod_js for Apache may suit your needs.

If you're just using plain JS, Crowbar might help you.

Is this really going to make things faster for users without causing compatibility issues?

There's John Resig's project Rhino; capable of running jQuery, Prototype, and MochiKit (at the very least)."