简体   繁体   English

ipad上的Javascript加载缓慢

[英]Javascript on ipad loads slow

I have a basic html site (html5 , JavaScript, jQuery) that I have running on an iPpad2. 我有一个基本的HTML网站(html5,JavaScript,jQuery),我在iPpad2上运行。 I do basic testing with a Google Chrome, just to test layout images and copy etc. My real test however needs to be on an actual iPad. 我使用谷歌浏览器进行基本测试,只是为了测试布局图像和复制等。我的真实测试需要在真正的iPad上。

On the iPad, my code seems to have a 2-4 second delay as compared to Chrome which loads instantly. 在iPad上,我的代码似乎有2-4秒的延迟,而Chrome则立即加载。 I have been unable to find the bottleneck. 我一直无法找到瓶颈。 I added alerts at various points in the code, but all the alerts appear immediately, one after the other and it seems the delay occurs after the last alert which is at the last line of code. 我在代码中的各个点添加了警报,但所有警报立即出现,一个接一个地出现,似乎延迟发生在最后一个代码的最后一个警报之后。

The alerts may be misleading as maybe the code is cached before its executed? 警报可能会产生误导,因为代码在执行之前可能会被缓存? Is there something I should look for or avoid in my code in order to speed things up on the iPad? 为了加快iPad上的速度,我的代码中是否应该寻找或避免?

If you do not cache your selector results - mobile devices are susceptible to poor performance 如果您不缓存选择器结果 - 移动设备容易受到性能影响

what I mean is if you do this: 我的意思是如果你这样做:

$("#someId").css(some, stuff);
$("#someId").css(other, stuffs);
$("#someId").attr(even, more);

compared to 相比

var ourElement = $("#someId");
ourElement.css(some, stuff);
ourElement.css(other, stuffs);
ourElement.attr(even, more);

now if you are doing the prior "in the real world" - in loops, etc.. - it can amount to a huge performance detriment to mobile devices 现在,如果你正在做“在现实世界中”的先前 - 在循环中等等 - 它可能对移动设备造成巨大的性能损害

good luck 祝好运

An iPad is considerably slower than a desktop running Google Chrome would be. iPad比运行谷歌浏览器的桌面慢得多。 It's expected to take a bit longer to do things. 预计需要花费更长的时间来做事。

If it was 10-20 seconds, I'd say check your code, but 2-4 seconds isn't unreasonable for a page load. 如果它是10-20秒,我会说检查你的代码,但2-4秒对于页面加载是不合理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM