Asked By: Anonymous
What I’m trying to do is build a simple app in PhoneGap and Backbone.js. The app has a login page which, on a successful login, sends the user to a simple menu with a few options. The user has the option to view their saved lists, view a list of items or view an info page. I know how I want to structure all of the Views and Models so the question I have is whether or not doing this all on one page has any downsides when compared to using multiple pages.
To break it down into smaller parts:
- If the router closes, .remove() and .unbind(), all the current view when switching to a new view, do I still risk memory issues?
Answered By: Anonymous
Backbone was designed to be built for SPA applications. Im not saying that you can’t span Backbone over multiple pages, but in my opinion that adds more complexity. From your description, I would keep your application as an SPA.
Secondly, build your application using modules. Use a library such as require.js. I could not recommend it enough. I wont go into too much detail about why you should use it, because you can read more about it here (I would recommend reading the entire book). Once your application is ready for deployment, you can use r.js, require.js’s build script. This will concatenate all or some of your modules into a single file. This will drastically speed up the performance of your app especially if you have a bunch of modules.
Finally with regards to memory optimization, I use a method developed by Derick Bailey which you can read up about here.
Hope this helps.