最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Backbone.js and PhoneGap, single or multi page? - Stack Overflow

programmeradmin2浏览0评论

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 pared to using multiple pages.

To break it down into smaller parts:

  1. Does loading all the javascript in the one page have serious performance implications?
  2. If the router closes, .remove() and .unbind(), all the current view when switching to a new view, do I still risk memory issues?

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 pared to using multiple pages.

To break it down into smaller parts:

  1. Does loading all the javascript in the one page have serious performance implications?
  2. If the router closes, .remove() and .unbind(), all the current view when switching to a new view, do I still risk memory issues?
Share Improve this question asked Aug 29, 2012 at 15:17 Jdeer_KKullenJdeer_KKullen 731 silver badge4 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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 plexity. 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 remend 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 remend 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.

发布评论

评论列表(0)

  1. 暂无评论