Node.js Question:

Can we use jQuery with Node.js?

Tweet Share WhatsApp

Answer:

No. It's going to be quite a big effort to port a browser environment to node.

Another approach, that I'm currently investigating for unit testing, is to create "Mock" version of jQuery that provides callbacks whenever a selector is called.

This way you could unit test your jQuery plugins without actually having a DOM. You'll still have to test in real browsers to see if your code works in the wild, but if you discover browser specific issues, you can easily "mock" those in your unit tests as well.

I'll push something to github.com/felixge once it's ready to show.

Download Node.js PDF Read All 15 Node.js Questions
Previous QuestionNext Question
Tell me how to decide when to use Node.js?How to extract POST data in node.js?