问题描述
最近,我一直感觉 jQuery 逐渐成为JS库中的事实上的标准(我可能错了! ),或者至少比其他框架更活跃.
Lastly I've been feeling like jQuery is slowly becoming the defacto standard in JS libraries (I might be wrong!), or at least that is more active than the rest of the frameworks.
例如,我一直在寻找像Componente这样的开源日历,并且找到 http://fullcalendar.基于jQuery的vinsol.com/.
For example, I've been looking for a fine open source calendar like Componente and found http://fullcalendar.vinsol.com/ which is based on jQuery.
我们一直在使用Prototype做很少的事情,例如它的选择器功能(主要是$
作为document.getElementById
的快捷方式),在页面加载时执行一些JS并发出一些非常简单的方法Ajax调用.
We've been using Prototype for very little things, like its selector capabilities ($
function as a shortcut for document.getElementById
, mainly), executing some piece of JS when the page is loaded and to issue some very simple Ajax calls.
所以我想迁移应该很简单,但是我想知道从Prototype迁移到jQuery的利弊.
So I guess the migration should be quite straight forward, but I'd like to know the pros / cons of migrating from Prototype to jQuery.
另一方面,我认为将它们放在一起并不是一个好选择,特别是考虑到迁移应该非常简单.我说的对吗?
On the other hand, I guess that having both of them together is not a good choice, specially taking into account that the migration should be quite simple. Am I right?
一些有用的资源:
- 您如何将网站从Prototype切换到jQuery
- jQuery&原型冲突
- 从原型转换为jquery
- http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks
- How would you go about for switching a site from Prototype to jQuery
- jQuery & Prototype Conflict
- converting from prototype to jquery
- http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks
推荐答案
原型和JQuery涵盖了非常相似的字段.多年来,我已经使用Prototype作为主要的JS框架,并且正在向JQuery迁移.原因如下:
Prototype and JQuery cover very similar fields. I have used Prototype as my main JS Framework for many years professionally, and I'm migrating to JQuery. Here's why:
-
jQuery的运行速度更快.原型在我见过的所有所有性能比较中排在最后(随机选择此处).我也有一个很长的主观印象,即原型的效果总体上较慢,尤其是在较旧的机器上.
JQuery is faster. Prototype comes last in all performance comparisons I've seen (Random pick here). I also have a long-standing subjective impression that Prototype's effects are slower overall, especially on older machines.
JQuery似乎不仅在Stack Overflow上更受欢迎,而且在Stack Overflow上也更受欢迎.这意味着更容易获得支持,并且可用插件和现成代码的数量要多得多.这不是我的中心原因,而是与jQuery是技术上更可靠的平台的总体印象一起,选择变得显而易见.
JQuery seems to be more popular, not only, but also, on Stack Overflow. Which means it is way easier to get support, and the number of available plug-ins and ready-made code is much larger. That's not the central reason for me but together with the overall impression that jQuery is the more technically sound platform, the choice became obvious.
我唯一不喜欢的是:
- jQuery代码往往看起来很恐怖.我非常喜欢JQuery及其哲学 ,但是我经常讨厌看代码.如果有人提出了一种看起来像普通的JavaScript一样美丽和结构化的JQuery方言,那么我很乐意加入. :)
- JQuery code tends to look horrible. I like JQuery and its philosophy very much, but I often hate looking at the code. If somebody came up with a dialect of JQuery that looks as beautiful and structured as plain vanilla JavaScript, I'll gladly be on board. :)
评论:关于我不喜欢jQuery编码风格的其他说明.
Re the comments: Additional clarification about what I don't like about jQuery's coding style.
一个词:方括号.成千上万:)
In one word: Brackets. Thousands and thousands of them :)
尽管如此.我意识到,所谓的"jQuery风格"大部分是快捷键和速记键,这些键和速记键是完全可选使用的.不过,从代码的可读性和可维护性的角度来看,我发现更大的jQuery代码很多更加难以阅读和理解.是的,随着jQuery经验的增长,这将变得更加容易,但是,我希望我的代码甚至对所有外部人员都可读.关于这一点,jQuery并没有朝着正确的方向发展.大部分代码都很丑陋.这是迄今为止我对这个出色框架的唯一主要批评.
Seriously though. I realize that much of what is considered "jQuery style" are shortcuts and shorthands that are entirely optional to use. Still, from a code readability and maintainability perspective, I find large chunks of jQuery code much more difficult to read and get into. Yes, that will become much easier with growing jQuery experience, but, I want my code to be readable even to a total outsider. In regards to that, jQuery is not going into the right direction IMO. Much of the code is plain ugly. It is my only major criticism of this great framework to date.
虽然方法链接,@ noah和诸如新的.delay()
之类的东西或它的名字,我认为这完全是摇滚.我不是反对这个.
Method chaining though, @noah, and stuff like the new .delay()
or what its name was, I think totally rock. I'm not saying anything against that.
这篇关于我应该从原型转移到jquery吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!