Live data from Hacker News

Avoiding Common Backbone.js Pitfalls

ozkatz.github.com

11–15 of 15 posts

Re: Avoiding Common Backbone.js Pitfalls

#11

For those who have not yet tried it, I would highly recommend TIm Branyen's Backbone.LayoutManager [1]. It solves items 1 and 2 very well. [1] https://github.com/tbranyen/backbone.layoutmanager

I've used Marionette up until now but this is very interesting. It looks like this solves one problem really well, but marionette solves a bunch of other problems with views/app management.

Re: Avoiding Common Backbone.js Pitfalls

#12

Great article highlighting some common areas for attention -- especially when first moving from vanilla jQuery to something like Backbone ... but important for any basic Model/View layer separation. For what it's worth, all 5 of these points are addressed by the Backbone docs, and there are some further nuances worth mentioning: 1. listenTo() is great when you're connecting from an object (frequently a View) that wil…

[deleted]

Re: Avoiding Common Backbone.js Pitfalls

#13
Respectfully disagree with point 3 - "Doing unnecessary XHR requests on page load".

It's better to have your main app page completely static so it can be cached. That said, don't use ajax either - load the initial data via its own script tag.

Re: Avoiding Common Backbone.js Pitfalls

#14
post #13

Respectfully disagree with point 3 - "Doing unnecessary XHR requests on page load". It's better to have your main app page completely static so it can be cached. That said, don't use ajax either - load the initial data via its own script tag.

Doesn't that also involve an extra HTTP call? I discussed the same issue as OP a while ago: http://branchandbound.net/blog/web/2012/11/unify-server-side...

Someone in the comments there mentioned a nice alternative to embeddding the data in a tag to avoid the problem jashkenas raised ( in the JSON). Namely, setting it in a data- attribute.

Re: Avoiding Common Backbone.js Pitfalls

#15
post #13

Respectfully disagree with point 3 - "Doing unnecessary XHR requests on page load". It's better to have your main app page completely static so it can be cached. That said, don't use ajax either - load the initial data via its own script tag.

Still, optimizing the initial load is a good idea for applications like this. As an alternative, you could create an API service that returns all relevant information for the first page view in one block, instead of half a dozen smaller AJAX requests.
Post reply on HN