简体   繁体   English

我可以合理地假设使用JavaScript的移动浏览器也支持jQuery吗?

[英]Can I reasonably assume mobile browsers with JavaScript also support jQuery?

I realise that this question may be almost impossible to answer definitively, but: 我意识到这个问题几乎不可能完全回答,但是:

Is it reasonable to assume that mobile browser with JavaScript can also cope with jQuery? 假设带有JavaScript的移动浏览器也可以应对jQuery是否合理 We're talking relatively basic jQuery such as click events and Ajax. 我们正在谈论相对基本的jQuery,例如点击事件和Ajax。

I'm writing a mobile HTML app. 我正在写一个移动HTML应用程序。 It involves slippy maps so anyone who wants to use it has to have JavaScript. 它涉及滑动地图,所以任何想要使用它的人都必须拥有JavaScript。

I'd much prefer to use jQuery for the rest of the coding if possible, but can I reasonably say to the client "any phone with JavaScript should support basic jQuery"? 如果可能的话,我更喜欢在其余的编码中使用jQuery,但是我可以合理地对客户说“任何带JavaScript的手机应该支持基本的jQuery”吗?

I know about jQuery mobile, but I'm specifically talking about phones that aren't advanced enough to handle jQuery mobile, but do have JavaScript. 我知道jQuery mobile,但我特别谈到的手机不够先进,无法处理jQuery手机,但确实有JavaScript。

Thanks! 谢谢!

Yes. 是。

jQuery is not a language. jQuery不是一种语言。 It is a library written in JavaScript, and therefore if you can run JavaScript reasonably well, you should be able to run jQuery without any problems. 它是一个用JavaScript编写的库,因此如果你能够很好地运行JavaScript,你应该能够毫无问题地运行jQuery。

With that being said, nothing compares to actual testing. 话虽如此,没有什么比实际测试更好。 Periodically check that your code works across multiple platforms (not only on different phones, but different web browsers as well). 定期检查您的代码是否适用于多个平台(不仅在不同的手机上,而且在不同的Web浏览器上)。

javascript is javascript. javascript是javascript。 You can always use jQuery.support to detect features . 您始终可以使用jQuery.support检测功能 You should test on the browsers you want to support anyway. 您应该在您想要支持的浏览器上进行测试。

The answer is simple: yes. 答案很简单:是的。

JQuery, and especially its most basic features, is designed to be cross browser. JQuery,尤其是其最基本的功能,旨在跨浏览器。 If the mobile browser has reasonable javascript support, JQuery should not be an issue. 如果移动浏览器有合理的javascript支持,JQuery应该不是问题。

For fallbacks on features you aren't sure whether or not are supported, you can use jquery.Support or Modernizr 对于功能的后备,您不确定是否支持,可以使用jquery.SupportModernizr

It should run okay on most... don't expect much from explorer pocket. 它应该在大多数情况下运行良好...不要期望从探险家的口袋里多少。

Although jQuery functions across these browsers, IRL many of the cool effects that jQuery makes simple won't be seen on a mobile browser, because the interface is so different. 虽然jQuery在这些浏览器中起作用,但是IRL在移动浏览器上看不到jQuery所带来的许多很酷的效果,因为界面是如此不同。 There is (almost) no concept of mousedown, mouseup, or hover; (几乎)没有mousedown,mouseup或hover的概念; click and focus behave differently, screensize is different vs effective window size, animations are slow, etc. The challenge in mobile browsers is mostly in the interface design. 点击和焦点表现不同,屏幕尺寸与有效窗口大小不同,动画速度慢等。移动浏览器的挑战主要在于界面设计。 The main advantage IMO is AJAX-loaded content, for speed and low data/bandwidth usage. IMO的主要优点是加载AJAX的内容,用于速度和低数据/带宽使用。

In short: yes. 简而言之:是的。

HOWEVER, if you're only doing Ajax and other little things, you'll see a significant speed gain just using vanilla JS. 但是,如果你只是在做Ajax和其他一些小事情,你会看到使用vanilla JS的显着速度提升。 But I do realize this can be somewhat of a pain. 但我确实意识到这可能有点痛苦。 There are lighter-weight packages out there, like xui . 那里有轻量级的包装,比如xui

Honestly, I'd consider programming separate sites for mobile Safari (iOS and Android), and other lower-powered devices that don't run WebKit. 老实说,我会考虑为移动Safari(iOS和Android)以及其他不运行WebKit的低功耗设备编写单独的站点。

To iterate again: jQuery.mobile is NOT a replacement for jQuery, but rather framework that builds on jQuery, much like jQuery-ui does. 再次迭代:jQuery.mobile不是jQuery的替代品,而是jQuery构建的框架,就像jQuery-ui一样。 This would be an even larger footprint and bootstrap time. 这将是一个更大的足迹和自举时间。

您可以查看http://jquerymobile.com/ - 也许这是您应该在页面上使用的而不是“常规”jquery。

Yes but you will better off using jQuery Mobile in case you are developing for mobile devices. 是的,但如果您正在为移动设备开发,最好使用jQuery Mobile。 It's optimized for them. 它针对他们进行了优化。

查看jQuery mobile ,以及这个信息丰富的slidehare ,它描述了您遇到的问题的范围和难度。

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

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