未加星标

JQuery-Free Rails and Legacy Browsers

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

You may have heard that Rails 5.1 will no longer depend on JQuery. Here's the PR .

Now, you might be asking yourself: "Why would a Ruby framework have a dependency on JQuery in the first place?" The answer lies in in Rails' unobtrusive javascript system. That's the bit that makes it possible to do things like:

link_to "delete", delete_path, remote: true, method: destroy

In order to remove this dependency, the UJS system has been ported to vanilla JS. It's also been given a new gem name. Instead of requiring the jquery-ujs gem, we'll be requiring the rails-ujs gem.

Legacy Browser Support

The one major drawback to eliminating JQuery is that UJS will no longer support older browsers as well as it used to. One of the reasons for JQuery's size and complexity is that it does support legacy browsers.

This potential issue was hinted at in the original Github issue, but nobody specifically mentioned which browsers would be unsupported. That's why I thought it would be interesting to run some tests.

I ran the test suites for jquery-ujs 1.2 and the latest rails-ujs (Jan 5, 2017) on IE 8-11. Chrome (55.0.2883.95) was used as a control. Microsoft provides free VMs for testing, if you're playing along at home.

Browser jquery-ujs test failures rails-ujs test failures Chrome 0 of 110 0 of 110 IE11 3 of 110 Tests won't run IE10 4 of 110 119 of 122 IE9 4 of 110 119 of 122 IE8 14 of 110 118 of 122 Conclusions

Neither of the test suites worked perfectly in IE, but the jquery-ujs suite fared much better. The new Rails UJS system seems to be completely unsupported on IE10 and down. I was unable to get a good reading on IE11 as a the test suite refused to run.

Supposedly it will be possible to load the older jquery-ujs gem on top of the new rails-ujs to bring back legacy browser support. I haven't had a chance to see if it works yet.

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

主题: ChromeGitRubyJava
分页:12
转载请注明
本文标题:JQuery-Free Rails and Legacy Browsers
本站链接:http://www.codesec.net/view/532589.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(65)