I was luckily enough to listen to the great Pamela Fox give a presentation on Backbone the other night. What follows are a few nuggets of gold I gleaned.
Since Backbone is lightweight there are multiple ways to do the same thing – find what way works best for you and your project.
Sometimes Backbone solves problems and sometimes it creates problems (see anchor tags).
Be aware of crazy state related bugs that can manifest in a single page app.
Just render the part of the DOM that has changed.
Don’t optimize prematurely – you can waste time on “fixing” things that don’t make a big enough of an impact in performance to matter. The best way to go about things is to do things the ‘crappy way’ first and check to see how well it performs.
Also, don’t guess what is causing performance issues – use DevTools!
Your code will either be clean or it will perform well, but not both – good performance usually ends with ugly code.
A lot of AJAX requests are a big perf issue; you can use RequireJS to get the client just what they need.
Also, using Require will eliminate global variables and thus collisions with variable names.
Speaking of variable names, proper naming conventions in the beginning will reduce confusion and headaches down the road.
Keep in mind: performance and perceived performance – if you just give the client SOMETHING in the beginning and then update it when they actually have the data they won’t feel like they are waiting. And are they really going to be interacting with everything that quickly? Probably not.
DO NOT rewrite functioning code unless it makes a DRASTIC improvement BECAUSE YOU WILL BREAK SOMETHING!!!
If your company/team/self doesn’t have or write tests be that person than complains that you should. You can go so far to write a postmortem and point out the time/energy wasted that could have been avoided with some tests.