Skip to content

Instantly share code, notes, and snippets.

View dwalend's full-sized avatar

David Walend dwalend

View GitHub Profile
@dwalend
dwalend / pre-render.js
Last active August 29, 2015 14:27 — forked from mef/pre-render.js
proof-of-concept pre-rendering d3.js svgs on the server using node.js and jsdom module.
// pre-render d3 charts at server side
var d3 = require('d3')
, jsdom = require('jsdom')
, fs = require('fs')
, htmlStub = '<html><head></head><body><div id="dataviz-container"></div><script src="js/d3.v3.min.js"></script></body></html>'
jsdom.env({
features : { QuerySelector : true }
, html : htmlStub
, done : function(errors, window) {