Do not “learn” jQuery, learn backbone.js and require.js

So you wanna join the little HTML5 party some of us are having? Great! It’s not that packed yet, quite comfortable actually. And the main gigs haven’t even played yet. So no, you’re not late. Quite one time actually.

Dear JavaScript pros: This is a blog post for beginners. So don’t shoot me for simplifying things.

Many developers (especially from the Flash / ActionScript community, but not only them) are currently wanting to “learn” HTML5. Some want to focus on websites, others want to build (single-page-) apps. Some want to do shiny advertising’ish projects, others want to focus more on “products”. And many say, that therefore they need to learn jQuery now.

Do not learn jQuery, just use it!

When someone asks you if you’re into jQuery, just confirm. Chances are, that clients/employers won’t mind to ask, since they assume that you do.

My prediction is, that you’ll use 10 jQuery methods max in the beginning. When starting with jQuery, using jQuery is mostly understanding HTML and CSS (you understand HTML and CSS, right?). Anyway, api.jquery.com is your friend. In a year from now, you’ll probably laugh about your jQuery code, but that’s ok for now, you have bigger problems.

How to produce clean code in JavaScript

The more important question is, how to build clean, manageable, understandable and maintainable JavaScript code. And unlike two years ago there are two industry standards now: backbone.js and require.js.

Backbone enables you to write a class-like code structure, that fulfills all the aforementioned criteria. And – most importantly – since it so widespread many people already know it. For me, working with backbone made working in big teams possible (you want to work in big teams, right?). There are many other frameworks out there, lots of them with a strong feature set. However, what I like about Backbone that it does not have a big feature set.

Require on the other side, not only encourages you to write loosely coupled and granular parts of code but also helps you to structure the JS files that hold your code. It makes you create JavaScript modules in a standardized way, so that you can easily plug them together. I know first hand, how hard it is in the beginning to decide how to organize the JavaScript files/folders and how to get them into the application. Require.js is there for exactly that.

So how to learn them then?

While understanding require is quite straight forward (the documentation will do), the learning curve of backbone is harder. Try to avoid the famous ToDo list example. It gives the impression that backbone applications are always big and/or complicated. The truth is backbone can be extremely simple. Start with something waaaaay simpler.

Unlike other coding communities, the JavaScript community is almost entirely based on open source. It basically lives on github. This includes backbone and require. So if you don’t already have a github account – go and get one. And hang out there for a while.

Other things you might want to check on github:
* HTML5 Boilerplate (especially the .htaccess file is very interesting)
* Twitter Bootstrap issues
* Modernizr
* Good list of things to look into

Comments