Designing Ajax from the Ground Up
In some ways, adding Ajax to an existing site is much easier than developing an application with Ajax as a component from the beginning. First of all, you already have your script-free application versions, and you won't be tempted to skip this essential component.
After doing the preliminary development planning discussed in Chapter 1, and after you have a good idea of where you want to use Ajax (and why), you now have design issues related purely to the development process.
Packaging Your Functionality into Units
It's a given that we'll package our JavaScript into reusable libraries, but we don't think about packaging our CSS or our HTML, not to mention also packaging our server-side code. A framework takes care of much of this, but we also need to look at going beyond the framework and discovering how much functionality we can package into complete units, such as CSS, HTML, server-side framework, and Ajax/scripting. This is dictated by common sense, of course, because we can easily make our sites impossible to maintain in our efforts to reduce it all to the lowest common denominators.
For instance, rather than having the CSS for an entire site in one file, we could split it out into separate CSS files for individual effects, and then load each of the CSS files only when the page needs a particular effect. Of course, the more we do this, the more HTTP requests are made, so another approach is to manually merge the CSS for all the effects into one ...
Get Adding Ajax now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.