Login Register

Dojo and Client-Side Rendering vs. Server-Side

At my job, we're pretty die-hard server-side development junkies. JSP and PHP are our bread-and-butter. When AJAX came along and we saw what could be done for user-interfaces, we pushed more of it to JavaScript, but we still generated it all in JSP.

We didn't see Dojo 0.9 as changing that equation much ... until we started having performance problems with our JSP's. We use filters a lot - combo box-controlled interfaces where changing filters on the top narrows yours results in a grid. We would generate these grids -- all the TR's and TD's -- by JSP. For fairly normal data sets, this would translate to downloading 6MB of HTML. And it got shoved into a tables's InnerHTML, taking as long as a minute to pop up.

We needed help. So we thought - what if we generate just the data, pass it to JavaScript, let it build a DOM tree, and insert that?  I had conversations with Eugen Lazutkin back in May where he'd told me about this approach using Dojo.  It would eliminate having to assemble HTML by the JSP, only to have it reparsed again at the client. So we used:

  • JSON for passing the data.  This decreased the network traffic from 6MB to 150K.
  • dojo.xhrGet to do all the communication and rendering

The results were amazing!  The app performance improved by orders of magnitude - from minutes to seconds to render a grid.  We became instant heroes to our customers.

While Dojo itself is a great toolkit in itself, it also promotes a new way of looking at web apps.    We're convinced!  And I'm sure we'll be using Dojo for more and more in the coming months.