1

JQM 文档说最好使用多个页面以避免拥有可能导致浏览器崩溃的大型 DOM。但是,多大才算太大?较大的多页文档似乎性能最好。有没有人对此有经验法则,或者何时最好有一个多页文档,VS 多个文档?

4

1 回答 1

2

To be honest it depends on several factors.

If you are building classic web page and you don't have server side code I would advise you to stick with multi-page layout. It is much easier to change/handle one large HTML page then several of them. There's no need to worry about javascript and css initialized inside your HEAD. Web app needs to be VERY large for performances to degrade. Performances will never degrade on desktop browsers but mobile ones are problematic (of course if web app is huge).

If you are building a large static web app or if you are using server side for code generation then I would advise you using multiple pages. In case of large static web app you can always remove pages from the DOM and prevent cashing. On the other side it is extremely silly to use server side page generation with just one HTML page.

Now comes the problematic part. If you are creating a hybrid mobile app using jQuery Mobile and Phonegap it is advised to use multi-page document. While this idea looks silly it will provide you will smother transitions then multiple pages template. Unfortunately you will need to take special care here. Don't create large app, if possible generate dynamic content and remove it when it is not needed any more.

Multiple pages can also be used successfully on mobile devices but its implementation should be a little different. If possible pages should be loaded before transition can occur and removed when they are not needed any more. This solution is probably less resources heavy the previous one but page handling (cashing and removing) makes it more difficult.

Here's also my blog article about this topic.

于 2013-06-04T18:03:55.747 回答