Let's suppose I am programming Facebook (which i'm not), or some other site that involves heavy traffic. Our general Layout is: All CSS is in external files 99% of JS is in external files the back bone of the websites HTML is generated by a PHP/MySQL backend, then we have JS functions to generate the DOM of parts that commonly change. Our server has an inplace API that returns JSON objects that are fed to our DOM builders (JS functions), which take an JSON object array of lets say, a list of friends, then generated ALL the html used for displaying a list of friends, or events, etc. Is this reasonable? Is it common practice to have dedicated JS functions to build the DOM as I have mentioned? Is this scalable? Is JS too slow? (btw, we use JQuery almost exclusively) I know that it tremendously lowers bandwidth and server load, as the server is no longer iterating through a list of friends (of which it also queried for via MySQL) and generating all the HTML, but instead making a query and returning a small JSON object. which seems ok to me, but I would like a 2nd/3rd/4th/... opinion. Thanks alot! Let me know if I am missing any critical information.
A:
Given that JS engines are being constantly developed towards improved performance, I think it's a pretty good design. We will be seeing it more and more often as HTML5 & Co gains popularity.
Mchl
2010-07-27 17:29:40
Thanks alot for the quick response!
KennyCason
2010-07-27 17:33:39
A:
This is the approach I'm moving towards. I'm pretty happy with it. JS is certainly not too slow. You'll want a good JS templating system. Trimpath JS Templates is my favorite of those I've tried.
morgancodes
2010-07-27 17:32:45
Let me know how you make out and what sort of resources you come up with. I've collected and built a nice bunch of tools which I feel really comfortable with. One day I'll document/share them all, I hope.
morgancodes
2010-07-27 21:40:00
Will do. yeah i'm in the process of finding that nice set of tools as well as a nice working scalable design. seems like a never ending process. :P
KennyCason
2010-07-28 15:28:29