Search code examples
node.jsyui

YUI running on node.js


Several UI libraries/frameworks are being ported to node.js, for example YUI (http://yuilibrary.com/projects/nodejs-yui3/).

What is the use case for this? What are the pros and cons of manipulating the DOM server side rather than in browser?


Solution

  • It's not a matter of using the DOM on the server instead of the client. It's a matter of using the DOM on the server instead of writing HTML or rendering views. You will still manipulate the DOM on the client aswell.

    The main pro of using the DOM instead of other methods is doing the manipulation for browsers with javascript disabled.

    The second pro is using the exact same code for your client side mvc on the server. This means rather then using views and templating engines you can just manipulate the html response through the DOM.

    The main disadvantages are using code tailored for the browser. So this code is not optimised nor is it the best solution for the server.

    Manipulation your html output through jsdom rather then views / templates is a valid thing to do and it's just an alternative way of generating the HTML your sending to the client.

    The alternatives to jsdom are preprocessors like jspp which render like PHP or ASP or Templating engines like Jade that are generally used with express