A while back, I wrote about asynchronous template loading for Backbone applications. At the bottom of that post, I showed some code that I wrote which would limit the number of AJAX calls that are made to the server, to one per resource. That way we wouldn’t end up with multiple calls to the same template, wasting precious network time.
Well it turns out I was on the right track, but Jim Cowart has a much better implementation of this as a jQuery plugin called TrafficCop. Using this plugin, I was able to reduce my code from the above to this: