jQuery和Prototype目前有什么区别? [英] What are the current differences between jQuery and Prototype?

查看:64
本文介绍了jQuery和Prototype目前有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近几个月我一直在构建一个Ruby on Rails网站,我只使用了少量内置的JavaScript函数。但是我将在未来几周和几个月内进行更多的JavaScript开发,我正在讨论要使用哪个JavaScript框架。

I've been building a Ruby on Rails site in recent months and I've only used a small amount of built in JavaScript functions. However I will be doing much more JavaScript development in the coming weeks and months and I am debating on which JavaScript framework to go with.

一方面jQuery似乎是更受欢迎的一个,但是再次Prototype已经内置到Rails中。几年前我还在线阅读了一些文章,讨论了jQuery在某些方面是如何更简洁,但在其他方面却很邋and,并提出了各种其他意见。

On the one hand jQuery seems to be the more popular one, but then again Prototype is already built into Rails. I've also read a bunch of articles online from a few years ago talking about how jQuery is more concise at some things but sloppy on others, and giving various other opinions.

所以我的问题是那些同时使用(最近最近)的人:

So my questions are to the people who have used both (preferably recently):


  • 有什么区别从纯JavaScript和Ruby on Rails角度使用Prototype和jQuery?

  • 他们之间是否存在显着差异,或者他们现在在功能和代码编写方面彼此非常接近?

  • 根据必须重新考虑的事项转换成本和必须重写的代码?

谢谢

推荐答案

上一次讨论

如果不是全部问题,那么很多已经讨论过了。请参阅 搜索 或:

Much, if not all of your question has been discussed already. See the search or:

  • How would you go about for switching a site from Prototype to jQuery
  • Prototype, dojo or jQuery?
  • Why does everyone like jQuery more than prototype/script.aclo.us or mootools or whatever?
  • Is it true that Jquery + Rails is problematic?
  • Using jquery in Rails

切换自原型到JQuery

我正在从Protoype转换到JQuery,主要是出于性能原因(我已经看到了太多基于Prototype的基准测试最后来到JQuery,MooTools和Dojo。)我认为转换成本并不可怕,因为大多数基本概念(选择,效果,Ajax)非常相似。但是,每一行Prototype代码都必须仔细重写 - 特别是因为许多辅助函数和结构( $ $$ )看起来欺骗性地相似。

I'm in the process of switching from Protoype to JQuery, mainly for reasons of performance (I have seen too many benchmarks with Prototype always coming in last to JQuery, MooTools and Dojo.) I would say switching cost is not horrible, because most basic concepts (Selection, Effects, Ajax) are very similar. However, every line of Prototype code has to be carefully rewritten - carefully especially because many helper functions and constructs ($ $$) look deceivingly similar.

如果您的代码包含许多可能在Jquery中可用的复杂链式构造,但功能不同,迁移可能会变得非常麻烦。如果你只使用它来快速选择$()元素,效果和一些Ajax,那就不用了。

If your code contains many complex chained constructs that may be available in Jquery as well, but function differently, migration can become a very cumbersome task. If you use it only for quick $() element selection, effects and a bit of Ajax, not so much.

无论哪种方式,都要为一个强烈的学习阶段做好准备。 JQuery构造虽然小而且聪明,但是阅读恕我直言是很糟糕的(与一个原生Javascript块相比看起来很糟糕,但这是一个不同的讨论)。如果您来自不同的框架或本机Javascript,那么熟悉语法和原则肯定需要时间。

Either way, be prepared for a phase of intense learning. JQuery constructs are small and smart, but are terrible to read IMHO (and look god-awful compared to a block of native Javascript, but that's a different discussion). It definitely takes time to get familiar with the syntax and principles if you're coming from a different framework, or native Javascript.

这篇关于jQuery和Prototype目前有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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