何时在jQuery Mobile中使用多页文档VS多页 [英] When to use a multi-page document VS multiple pages in jQuery Mobile

查看:114
本文介绍了何时在jQuery Mobile中使用多页文档VS多页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JQM文档说,最好使用多个页面,以避免使用大型DOM,而大型DOM可能会使浏览器崩溃.但是,太大太大了?对于较大的多页文档,性能似乎最好.有没有人对此有一个经验法则,或者什么时候有多页文档最好是VS多个文档的准则?

The JQM documentation says it is better to use multiple pages to avoid having a large DOM which could crash browsers. But, how large is too large? It seems like performance would be best with larger multi-page documents. Does anyone have a rule of thumb for this, or guidelines for when it is best to have a multi-page document, VS multiple documents?

推荐答案

老实说,这取决于几个因素.

To be honest it depends on several factors.

如果您要构建经典网页,但没有服务器端代码,我建议您坚持使用多页布局.更改/处理一个较大的 HTML 页面要比更改其中的多个页面容易得多.无需担心 HEAD 中初始化的javascript和CSS.网络应用必须非常大,以降低性能.在台式机浏览器上,性能永远不会降低,但在移动浏览器上,这是有问题的(当然,如果网络应用程序很大).

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).

如果您要构建一个大型静态Web应用程序,或者您正在使用服务器端进行代码生成,那么我建议您使用多个页面.如果是大型静态网络应用,则始终可以从 DOM 中删除页面并防止兑现.另一方面,仅使用一个 HTML 页面使用服务器端页面生成是非常愚蠢的.

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.

现在是有问题的部分.如果要使用jQuery Mobile和Phonegap创建混合移动应用程序,建议使用多页文档.尽管这个想法看起来很愚蠢,但它将为您提供更平滑的过渡效果,然后为您提供多页模板.不幸的是,您将需要在这里特别注意.不要创建大型应用,如果可能的话,会生成动态内容,并在不再需要它时将其删除.

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.

这篇关于何时在jQuery Mobile中使用多页文档VS多页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆