While everyone else is playing with React, I have spent the past year with my old trusty friend - Backbone.js. I really like Backbone. It stays out of my way and lets me get things done. Using a mature library shouldn’t mean we don’t get to play with new toys, however. I’m going to share my experiences, and hopefully encourage you to start writing Backbone.js code like this:
CommonJS and Transpiling
I do not recommend using ES2015 classes or inheritance with Backbone views,
models, or collections. Weird things
happen. I will not go into detail, but if you want to read more, the
issues are well documented here.
.extend just as you always have.
Are you tired of typing out
function? You don’t have to anymore.
Have you ever written
var self = this;? Of course you have, you’re a
functions are here to save you.
I prefer to use Handlebars.js to render templates. When I first started writing Backbone.js code, I was always faced with a difficult question:
Webpack loaders make this extremely easy. Go install the
from NPM and start doing things the easy way:
Your Backbone.js code can benefit from ES2015 just as much as newer frameworks and libraries. If you haven’t taken the plunge yet, It’s never too late.