There are only a few principles that drive a UJS design, but they can have profound impact on your design.
- Separation of Markup, Style and Behavior. This is a similar concept to Separation of Concerns when designing object oriented systems. And you get some of the same benefits of SOC and then some. There should be no style information or behavior information embedded into your HTML markup. Also, style and behavior should be in separate files when possible.
- Make No Assumptions. One of the most challenging aspects of web development is that as a web developer/designer, you have very little control of the environment your application is executed in. Not all browsers are created equal, the number of devices that are display web pages is ever increasing, and users have lots of options that can severely impact your design and functionality. Because of these challenges, you can take nothing for granted. You need to design your web site so that it will work regardless of the abilities of the rendering engine and user preferences.
- Progressive Enhancement. For browsers that have more capability, provide more functionality and better user experience.
- Follow W3C standards. Avoid using browser specific features and use the W3C DOM and event model to affect behavior and design. Not only will this broaden your user base, it will save you numerous cross-browser headaches.
Benefits from UJS
The next few blog posts will go into each of these concepts in detail. I will give examples of poorly designed markup and how to refactor them to a UJS style.