我应该从原型转移到 jquery 吗? [英] shall I move from prototype to jquery?

查看:24
本文介绍了我应该从原型转移到 jquery 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最后我感觉 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.vinsol.com/ 基于 jQuery.

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 涵盖的领域非常相似.多年来,我一直使用 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 更快.在我见过的所有性能比较中,原型排在最后(随机选择 这里).我也有一个长期的主观印象,即 Prototype 的效果总体上较慢,尤其是在旧机器上.

  • 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 上也是如此.这意味着更容易获得支持,并且可用插件和现成代码的数量要多得多.这不是我的核心原因,但加上 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 及其哲学非常,但我经常讨厌查看代码.如果有人想出一种 JQuery 方言,它看起来像普通的 JavaScript 一样漂亮和结构化,我很乐意加入.:)
  • 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 并没有朝着 IMO 的正确方向发展.大部分代码都很简单丑陋.这是迄今为止我对这个伟大框架的唯一主要批评.

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 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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