最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why does Ruby on Rails use Prototype.js by default? - Stack Overflow

programmeradmin2浏览0评论

I just recently started learning RoR and found that Prototype.js is a default javascript library ing from the box. Why does it use this library and why not jQuery, Dojo, Mootools, ExtJS etc.?

I just recently started learning RoR and found that Prototype.js is a default javascript library ing from the box. Why does it use this library and why not jQuery, Dojo, Mootools, ExtJS etc.?

Share Improve this question edited Jul 25, 2017 at 21:46 akrisanov asked Apr 20, 2010 at 21:15 akrisanovakrisanov 3,2146 gold badges36 silver badges57 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 7

It was a choice made about five years ago, and was basically just the favorite JS framework of DHH at the time. Rails 3 will support switching that easier, but for rails 2, you can always just use http://github./aaronchi/jrails to swap in jquery for prototype.

UPDATE: As of rails 3.1, it will use jquery by default, and prototype will bee available via a gem.

As Matt Briggs mentions, prototype was state-of-the-art 5 years ago.

TBH, it's been a very long time since I used the built in javascript helpers. I write my apps using unobtrusive JS techniques with jQuery rather than the defaults. All you need to do is delete the default files and include whatever library you want in your layout.

Rails 3 changes this limitation, btw by adding hooks for unobtrusive JS with any library.

If I recall correctly from the Prototype & Scriptaculous book, it was originally part of Rails and is now a spin-off. The point was to make JavaScript look and act more like Ruby.

At the time of the writing Prototype wasn't just the state of the art, it was THE library to use. However if you just use javascript_tag to require jQuery - it will work just fine, except to your rjs helpers. However that is changing in Rails 3 thanks to Merb influence and Yehuda Katz in particular (one, but not the only one, of the Rails 3 Core, Merb and jQuery core members)

It's very cool how munity drives the Rails framework now. After several years of having a mandatory JavaScript library, we finally got a freedom to choose favorite frontend libraries and tools: Rails 5.1: Loving JavaScript, ..

发布评论

评论列表(0)

  1. 暂无评论