nycynik
nycynik

Reputation: 7541

Backbone.js where to place logic

Using backbone.js and it's navigation/routes, and loading html template pages in from external files as we navigate around. The javascript for these pages are all excluded in one large javascript file for the entire app.

What are the tradeo-offs of moving the logic into tag in the file that we are placing on the page?

So far: Good:

Bad:

Upvotes: 0

Views: 215

Answers (1)

Eric Levine
Eric Levine

Reputation: 13564

You should really aim to keep your views (HTML, CSS, and templates) separate from your logic (JavaScript code). Otherwise, it will become really difficult to evolve your application as it grows and/or reuse code from one page to the next.

You might want to take a look at modularizing your Javascript with something like Require.js. This chapter in Developing Backbone.js Applications should help you get started: http://addyosmani.github.com/backbone-fundamentals/#advanced. Require.js has an optimizer which will deal combining and minifying your scripts for production, so that begins to address the size and loading issues.

Upvotes: 1

Related Questions