Check out the Web Camps TV interview with myself and Stephen Walther where we demo some of the new features:
Holy miracle, Batman!? Microsoft are contributing to open source!
Yes that’s right, Microsoft are contributing to jQuery, which is an open source project. That means we have real life developers working on shipping code – you can see what they’ve been up to on github. Boris Moore the lead dev on our contributions has been writing up his thoughts on working at Microsoft on an open source project which make for some interesting reading. He also provides some details on using the templating engine and some of the advanced features that all templating ninjas should know.
Why use jQuery Templates?
There are basically two reasons to use jQuery Templates:
- Maintainability of your code
On Performance. This benefit comes in two flavors, user experience and bandwidth.
First, let’s discuss user experience. Modern websites are behaving more and more like desktop applications, with data that is constantly being refreshed with no user interaction. Think about Twitter or Facebook and how they are regularly pulling data from the server to provide a refreshed look automatically. jQuery Templates make it simple to declare the shape of your HTML and then insert fresh data to them, appending the resultant HTML to the DOM where appropriate.
On Maintainability of your code
Pop quiz: which is easier to understand? This template?
or this concatenated string?
Hopefully the difference is clear
Who’s using jQuery Templates?
These bits are pretty fresh so there are only a few examples of websites using them. One early adopter is hiFi, a website publishing engine. They take performance seriously which is why they chose to use jQuery Templating engine to render their comments to the client. The team at hiFi have also written up a really nice post on the subject of jQuery Templates.
To get started with templates I recommend checking out the jQuery API documentation and also the samples that Boris has created on github.com. Rey Bango also has some great tutorials on the different ways you can declare templates too.