jQuery plugins with node.js


I’m using jQuery with jsdom in my node.js app.

Moreover, I want to use jQuery plugins(e.g. jQuery.diff), but I cannot find how to do this. Is there any way out?

Problem courtesy of: mhayashi


Create a script tag in your document to load your script into it. Example:

createWindow = function(fn) {
var window = jsdom.jsdom().createWindow(),
script = window.document.createElement('script');

jsdom.jQueryify(window, function() {
script.src = 'file://' + __dirname + '/some.library.js';
script.onload = function() {
if (this.readyState === 'complete') {

createWindow(function(window) {
// Do your jQuery stuff:

Source: http://blog.davidpadbury.com/2010/10/03/using-nodejs-to-render-js-charts-on-server/

Solution courtesy of: balu

View additional discussion.