Evil Blocks is a tiny JavaScript framework for web pages. It is based on 4 ideas:
- Split code into independent blocks. “Divide and conquer” is always a good idea.
- Blocks communicate with events. Sending and processing events is an easy and safe method to keep complicated dependencies between controls very clean.
- Separate JS and CSS. You should only use classes for styles and bind JS by special attribute selectors. This way, you can update your styles without fear of breaking any scripts.
- Try not to render on the client. 2-way data-binding looks very cool, but it has a big price. Most web pages (unlike web applications) can render all HTML on the server and use client rendering only in a few places. Without rendering, we can have incredibly clean code and architecture.
See also: Evil Front, a pack of helpers for Ruby on Rails and Evil Blocks.