在jQuery Mobile中加载大型嵌套列表的最快方法是什么? [英] What's the fastest way to load a large nested list in jQuery Mobile?

查看:115
本文介绍了在jQuery Mobile中加载大型嵌套列表的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很大的嵌套数组,是通过在PHP中解析CSV文件生成的.我用JSON输出它,并让我的jQuery Mobile站点获取它,然后将其解析为DOM列表<ul><li>.在我的台式机浏览器上,此方法运行良好,但似乎在移动设备上永久存在.

I have a large nested array that I'm generating from parsing a CSV file in PHP. I had it output it in JSON and had my jQuery Mobile site fetch it, then parse it into a DOM list <ul>, <li>. This worked fine on my desktop browser but seemed to take forever on my mobile devices.

因此,我让PHP脚本实际输出了HTML,并将其粘贴到我的jQuery Mobile网站中,以查看是否加快了速度.这实质上消除了对任何数据的获取. index.html只是其中有一个很大的嵌套<ul>.我认为这肯定会很快加载,但是现在在我的移动设备(Nexus One和Blackberry)上花费的时间甚至更长了.

So then I had the PHP script actually output the HTML, and pasted that in my jQuery Mobile site to see if that sped it up. This essentially removed the fetching of any data. The index.html simply has a very large nested <ul> in it. I figured this would definitely load quickly, but it seems to take even longer now on my mobile devices (Nexus One & Blackberry).

有什么办法可以加快速度吗?这是一个演示 http://pastehtml.com/view/bkrviwxp4.html

Is there any way to speed this up? Here's a demo http://pastehtml.com/view/bkrviwxp4.html

我在链接上尝试了数据预取,但是这阻止了页面完全加载到黑莓机上.

I tried data-prefetch on the link but that prevented the page from loading entirely on the blackberry.

推荐答案

如我所见,您正在一次处理所有元素,但是不会一次显示所有元素.尝试仅将这些将要显示的元素处理并添加到DOM中.即使只有一对元素,但您拥有数千个元素,JQuery-mobile本身也非常慢.

As I see, you're processing all elements at once, however you don't display them all at once. Try to process and add to DOM only these elements that will be displayed. JQuery-mobile is very slow by itself even if there's only a pair of elements, you have thousands.

这篇关于在jQuery Mobile中加载大型嵌套列表的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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