为什么每个javascript问题的答案最终都是“jQuery”

时间:2021-07-21 13:45:03

I've been following the javascript questions here for the last few weeks, and I've found a common recurring theme.

在过去的几周里,我一直在关注这里的javascript问题,我发现了一个常见的反复出现的主题。

Almost any question asked on here that involves JavaScript gets answered with:

几乎所有涉及JavaScript的问题都得到了回答:

  1. "jQuery can do that"
  2. “jQuery可以做到这一点”

  3. "there's a plugin for that"
  4. “那里有一个插件”

  5. "jQuery can make your bed for you."
  6. “jQuery可以为你铺床。”

Even questions referencing other libraries are answered by saying "Use jQuery instead".

甚至引用其他库的问题也可以通过说“使用jQuery”来回答。

Is jQuery replacing JavaScript as a whole?
This is a serious question. Are we really looking at JavaScripts future. Obviously this community has a strong bias towards jQuery (is that because there's alot of .NET developers?), but does the web development community as a whole share this bias?

jQuery是否取代了JavaScript作为一个整体?这是一个严重的问题。我们真的在关注JavaScripts的未来吗?显然这个社区对jQuery有很强的偏见(因为有很多.NET开发人员?),但是整个Web开发社区是否共享这种偏见?

13 个解决方案

#1


3  

I think jQuery can't replace JavaScript for a very obvious reason. It's because jQuery doesn't solve a single problem in JavaScript - the language. It only solves problems with inconsistent DOM implementations between browsers which is its biggest strength and it comes with some syntactical sugar.

我认为jQuery无法取代JavaScript,原因很明显。这是因为jQuery无法解决JavaScript中的单个问题 - 语言。它只解决了浏览器之间不一致的DOM实现的问题,这是它最大的优势,并且带有一些语法糖。

jQuery can't also replace the DOM APIs for another obvious reason. jQuery - the library, is controlled by one organization and primarily one man. DOM, on the other hand, is a spec that is implemented by tons of vendors while jQuery is merely a wrapper around the various implementations of that spec.

另一个显而易见的原因是jQuery也无法替换DOM API。 jQuery - 图书馆,由一个组织控制,主要由一个人控制。另一方面,DOM是由大量供应商实现的规范,而jQuery仅仅是该规范的各种实现的包装。

If jQuery were to replace these DOM APIs, then it will have to be a spec because different browser vendors can't just take its code and shove it in somewhere and make everything work nicely. The browser engine might be in C, C++, Java, or GolfScript so it becomes absolutely necessary for it to be a spec rather than an implementation.

如果jQuery要替换这些DOM API,那么它必须是一个规范,因为不同的浏览器供应商不能只是把它的代码拿到某个地方并使一切工作得很好。浏览器引擎可能是C,C ++,Java或GolfScript,因此它绝对有必要成为规范而不是实现。

Once jQuery API's become the de-facto standard and gets laid out in a spec, it will face the same problem that the specs face now. You can't just be a core-committer who fixes a problem overnight and releases a new version say 1.4.3 of the spec. The spec has be discussed, agreed upon, changed, released, and all implementors have to update their codebase to comply which makes the entire process slower. It also loses the ability to fix cross-browser quirks because it doesn't get to control that since its operating at a higher level in the food chain.

一旦jQuery API成为事实上的标准并在规范中得到规划,它将面临规范现在面临的同样问题。你不能只是一个在一夜之间解决问题的核心提交者,并发布一个新的版本说1.4.3的规范。规范已经讨论,同意,更改,发布,并且所有实现者都必须更新其代码库以符合这一要求,这会使整个过程变慢。它也失去了修复跨浏览器怪癖的能力,因为它无法控制它,因为它在食物链中的更高层次上运作。

Then, because of it being a spec and moving slowly, you can always come up with your own library *Query that simplifies the spec APIs even further, fixes cross-browser issues, and move at a much faster pace.

然后,由于它是一个规范并且移动缓慢,您可以随时提出自己的库*查询,进一步简化规范API,修复跨浏览器问题,并以更快的速度移动。

This is why jQuery can't replace the DOM API because if it does, it will stagnate rather quickly as better, more innovative, and competing abstractions spring up every single day.

这就是为什么jQuery不能取代DOM API的原因,因为如果它确实如此,它会停滞不前,因为每天都会出现更好,更具创新性和竞争性的抽象。

#2


22  

No, jQuery does not replace JavaScript, because it is JavaScript. But it helps you a lot, especially in selecting elements and applying functions on elements.

不,jQuery不会取代JavaScript,因为它是JavaScript。但它对你有很大的帮助,特别是在选择元素和在元素上应用函数时。

The probably most important argument for using jQuery: You don't have to think about cross-browser compatibility.
Seriously, the different JavaScript implementations in the browsers are driving me crazy.

使用jQuery可能是最重要的论点:您不必考虑跨浏览器兼容性。说真的,浏览器中不同的JavaScript实现让我发疯。

But I also don't think jQuery should be used for everything. It depends on where (e.g. which browsers) the JavaScript is used and what you actually do.

但我也不认为jQuery应该用于所有事情。这取决于JavaScript的使用位置(例如,哪些浏览器)以及您实际执行的操作。

And as I already answered on other question, you can only master jQuery if you understand JavaScript. It is very easy to write bad jQuery code if you don't understand how it works.

正如我已经在其他问题上回答的那样,如果你理解JavaScript,你只能掌握jQuery。如果您不了解它的工作方式,那么编写糟糕的jQuery代码非常容易。

Update:

In fact in modern browsers you can already do stuff you normally used jQuery for, like using selectors or each(), natively in JavaScript, with document.querySelectorAll() and the array method forEach().
But this is the problem: In modern browsers. jQuery ensures that you can use the same API and don't have to care about the browser version.

事实上,在现代浏览器中,您已经可以使用通常使用jQuery的东西,例如使用selectors或者每个(),本地使用JavaScript,使用document.querySelectorAll()和数组方法forEach()。但这就是问题:在现代浏览器中。 jQuery确保您可以使用相同的API,而不必关心浏览器版本。

#3


19  

I sort of have a bias against jQuery. It's my only ignored tag :)...

我对jQuery有偏见。这是我唯一被忽略的标签:)...

In my opinion, it is inappropriate for people to post into other questions saying "Can I haz jQueries?" when the other person is into "plain" JavaScript, though.

在我看来,人们不宜在其他问题上发帖说“我能不能jJeries?”但是,当另一个人进入“普通”JavaScript时。

I believe that everyone should learn "plain" javascript+dom manipulation BEFORE going into jQuery, sort of like how you shouldn't jump straight into DirectX when you learn c++; you can't work with jQuery without JavaScript know-how...

我相信每个人都应该在进入jQuery之前学习“简单的”javascript + dom操作,有点像你学习c ++时不应该直接跳到DirectX;没有JavaScript专有技术,你无法使用jQuery ...

In the end, though, you should use what you feel more comfortable with.

但最后,你应该使用你觉得更舒服的东西。

But in all honesty, I believe that you will have more opportunities if you also become proficient at JavaScript, and let's say jQuery does die out one day... Your experience with JavaScript itself will still be there.

但老实说,如果你也熟练掌握JavaScript,我相信你会有更多的机会,让我们说jQuery有一天会消失......你对JavaScript本身的体验仍然存在。

#4


4  

As I see it, JavaScript is ugly, error prone and a pain. I love the flexibility that allows for approaches such as jQuery, prototype.js, etc. However, the emergence of these libraries proves my point. Not all of this is JavaScript's fault. Some of it is due to the web browsers.

正如我所看到的,JavaScript是丑陋的,容易出错并且很痛苦。我喜欢允许jQuery,prototype.js等方法的灵活性。但是,这些库的出现证明了我的观点。并非所有这些都是JavaScript的错。其中一些是由于网络浏览器。

To better answer the actual question:

为了更好地回答实际问题:

jQuery just makes things easier, like any good library/framework should. This is the reason it gets suggested so much. It's just easier to do it in jQuery than plain JavaScript. Trying to explain all the minutiae to get plain JavaScript to work in a variety of situations can be a serious pain.

jQuery只是让事情变得更容易,就像任何好的库/框架一样。这就是它得到如此多建议的原因。在jQuery中执行它比在纯JavaScript中更容易。试图解释所有细节以使普通JavaScript在各种情况下工作可能是一个严重的痛苦。

That said, I agree. If someone is looking for just a JavaScript solution, that is what they should get. However, they should realize that it could be a difficult process and not everyone has the time/interest to go to that much trouble.

那就是说,我同意。如果有人正在寻找一个JavaScript解决方案,那就是他们应该得到的。然而,他们应该意识到这可能是一个艰难的过程,并不是每个人都有时间/兴趣去解决那么多麻烦。

#5


3  

Well I can't speak for everyone but jquery just makes javascript tasks easier. Not to mention that they are tested across multiple browsers so less concern with cross-compliant issues.

好吧,我不能代表所有人,但jquery只是让javascript任务更容易。更不用说它们在多个浏览器中进行测试,因此不太关心交叉兼容问题。

What you could write in 1 line of jquery could take you 10 or more with writing your own javascript. Also the benefit of using the library is that it has been tested for bugs that you don't have to worry about.

你可以用1行jquery写的东西可以带你10个或更多写自己的javascript。使用该库的好处是它已经过测试,您不必担心它们的错误。

Just my opinion.

只是我的观点。

#6


2  

Is jQuery replacing JavaScript as a whole?

jQuery是否取代了JavaScript作为一个整体?

The only thing I never saw addressed in this thread was this: jQuery cannot replace Javascript,,, it is Javascript. It's nothing more than a collection of pre-written functions in Javascript that takes care of a lot of commonly-used and desired requirements of many developers.

我从未在这个帖子中看到过的唯一一件事是:jQuery无法取代Javascript ,,,它是Javascript。它只不过是Javascript中预先编写的函数集合,它可以处理许多开发人员常用的和期望的需求。

Lets say you've always made your own paper (chop the wood, pulp it, dry it, decorate it, etc) before making your very special paper cut-outs. One day, while making paper cut-outs from your homemade paper, someone points out to you the wonders of pre-made paper (Oh happy day), and says "no need to make your own... get right to the fun of making paper cut-outs." You've never used pre-made paper... to you, paper is the result of a lot of time spent working with wood. So... now that you've discovered Acme Paper, would you ask if Acme Paper has replaced wood? Of course not... it's made from wood. Instead, you would suddenly think of Acme Paper as a time-saver, as a way to get to the final result of making cut-outs without all that wood-working hassle to make the paper itself.

可以说,在制作非常特殊的纸张切口之前,你总是制作自己的纸张(砍木头,纸浆,干燥,装饰等)。有一天,在用自制纸张制作剪纸的同时,有人向你指出预制纸张的奇迹(哦,快乐的一天),并说“不需要自己制作纸张......”制作剪纸。“你从来没有使用预制纸......对你而言,纸张是花在木头上的大量时间的结果。那么......既然你已经发现了Acme Paper,你会问Acme Paper是否已经取代了木材?当然不是......它是用木头做的。相反,你会突然想起Acme Paper作为一个节省时间的方法,作为一种方法来达到制作切口的最终结果,而没有任何木工工作的麻烦来制作纸张本身。

Likewise, jQuery (the 'brand-name' paper) doesn't replace the Javascript (wood) from which it was made, it just saves you the hassle of making your own utility functions (paper) before you get to the fun of making your own custom code (little paper cutouts).

同样,jQuery('品牌'纸)不会取代制作它的Javascript(木头),它只是让你省去制作自己的实用功能(纸张)的麻烦,然后才能获得制作的乐趣你自己的自定义代码(小纸剪纸)。

Have I confused the issue yet?

我把这个问题弄糊涂了吗?

Cheers!

#7


2  

I can't speak for the bias toward a particular framework, but usually using a framework trumps vanilla javascript when it comes to getting things done, and done right. David Walsh said it best here:

我不能代表对特定框架的偏见,但通常使用框架胜过vanilla javascript来完成工作,并且做得对。大卫沃尔什在这里说得最好:

http://davidwalsh.name/6-reasons-to-use-javascript-libraries-frameworks

#8


1  

If you're just using JavaScript to manipulate the DOM and do AJAX, why not use a framework to do the heavy lifting and grunt work?

如果您只是使用JavaScript来操作DOM并执行AJAX,那么为什么不使用框架来完成繁重的工作呢?

JavaScript does extend beyond web pages and the DOM too. See node.js for some serious awesomeness. For a small peek read this blog post (though it is more impressive with more people on at once).

JavaScript确实扩展到了网页和DOM之外。请参阅node.js以获得一些非常棒的功能。对于一个小小的偷看,请阅读这篇博客文章(尽管一次有更多人参与其中更令人印象深刻)。

#9


1  

It's the same thing as asking why there is a preference towards using any framework such as MVC .net, CakePHP etc. Speed, flexibility, reuse etc.

这与询问为什么偏好使用任何框架(如MVC .net,CakePHP等)的速度,灵活性,重用等等是一回事。

However, although frameworks do a whole bunch of cool stuff, in the end it doesn't replace the need to know and understand underlying language.

然而,虽然框架做了很多很酷的东西,但最终它并没有取代了解和理解底层语言的需要。

#10


1  

To me, jQuery is sort of like Cocoa for the Mac. I have read that the Cocoa framework is composed simply of many "low-level" Unix commands that are the base of the Mac OS. So when you do something as simple as allocating memory, these long-lost simple commands are run.

对我来说,jQuery有点像Mac的Cocoa。我已经读过Cocoa框架只是由许多“低级”Unix命令组成,这些命令是Mac OS的基础。因此,当您执行像分配内存这样简单的操作时,会运行这些长期丢失的简单命令。

I would not be surprised if the progression from Unix to Cocoa were to happen to Javascript into jQuery — after all, it would be easier to call a jQuery command that internally did 10 basic Javascript actions (especially if the command was commonly used). Personally, I am against it, because it limits the freedom of the developer. While others might argue it allows more creativity because it's easier/faster to build new/better things, people will rely on it, and eventually become dependent, and forget all about the basic core of Javascript.

如果从Unix到Cocoa的进展发生在Javascript到jQuery中,我不会感到惊讶 - 毕竟,调用一个内部执行10个基本Javascript操作的jQuery命令会更容易(特别是如果命令是常用的话)。就个人而言,我反对它,因为它限制了开发人员的*。虽然其他人可能认为它允许更多的创造力,因为它更容易/更快地构建新的/更好的东西,人们将依赖它,并最终变得依赖,并忘记了所有关于Javascript的基本核心。

What if a specific "handy-dandy, pre-made and ready-to-use" function for what you wanted didn't exist in the merry "simple" world of jQuery? If developers relied on jQuery, they'd be at a total loss. In my opinion, we developers must continue to be independent and create our own code, though using a little pre-made stuff doesn't hurt either.

如果在jQuery的快乐“简单”世界中不存在特定的“方便花哨,预先制作且随时可用”的功能,那该怎么办?如果开发人员依赖于jQuery,他们将完全失败。在我看来,我们开发人员必须继续保持独立并创建我们自己的代码,尽管使用一些预先制作的东西也不会造成伤害。

#11


1  

A following says a lot about an API or Framework. In general, more users will tend to generate better documentation. Documentation can go a long way in the adoption process.

以下是关于API或框架的很多内容。通常,更多用户倾向于生成更好的文档。文档可以在采用过程中发挥很大作用。

jQuery does have its limitations, at least at the time of the writing of this answer. For example, today I wanted to test functionality with a xhr that stays at readystate 3 most of the time. I decided I might be better off writing my own jQuery plugin instead of using the $.ajax that is commonly used. That wouldn't have been such a bad thing. However, I've come to appreciate that jQuery is tested on many versions of many different browsers. I can hit a target usability audience just by using one framework.

jQuery确实有它的局限性,至少在写这个答案的时候。例如,今天我想用大多数时间保持在readystate 3的xhr来测试功能。我决定编写自己的jQuery插件,而不是使用常用的$ .ajax。这不会是一件坏事。但是,我开始意识到jQuery已经在许多不同浏览器的许多版本上进行了测试。我只需使用一个框架即可达到目标可用性受众。

In the end, I could have experimented with $.ajax beforeSend to see if there was a way to attach a handler for readystate 3, but the documentation I was reading led me to believe that it would have been more work for the task I needed to accomplish.

最后,我可以尝试使用$ .ajax beforeSend来查看是否有一种方法可以为readystate 3附加一个处理程序,但是我正在阅读的文档让我相信这对我需要的任务来说会更有用。去完成。

Overall, I have to say that I've enjoyed jQuery more than the other frameworks I've tried. When something else comes along, I'll give it a try also.

总的来说,我不得不说我比我尝试过的其他框架更喜欢jQuery。当其他东西出现时,我也会尝试一下。

#12


1  

I've noticed the same thing lately. That jQuery - but take any other framework - destroys analytical thinking. Developers look at browser scripting as Duplo Lego when it's in fact Technics.

我最近注意到了同样的事情。那个jQuery - 但是采取任何其他框架 - 破坏了分析思维。开发人员将浏览器脚本视为Duplo Lego,而实际上是Technics。

jQuery, while an excellent tool for UI manipulation - doesn't cover every aspect of high level JS programming. What about data, for instance? jQuery is quite poor in that area, but still, when a problem arises that has something to do with sorting or filtering - we go instantly into searching for a jQuery plugin.

jQuery虽然是用于UI操作的优秀工具,但并未涵盖高级JS编程的各个方面。例如,数据怎么样? jQuery在这个领域相当糟糕,但是当出现与排序或过滤有关的问题时,我们会立即去寻找一个jQuery插件。

jQuery will not, can not replace JS as a whole.

jQuery不会,不能替代JS作为一个整体。

#13


0  

jQuery has become a defacto standard, the way that C or Java is for the desktop programming world - everyone knows it, or should as it provides common language. Typically everyone starts on jQuery and then learns about Javascript from their experiences and can look elsewhere.

jQuery已成为事实上的标准,C或Java用于桌面编程世界的方式 - 每个人都知道,或者应该提供通用语言。通常每个人都从jQuery开始,然后从他们的经验中学习Javascript,并可以在其他地方查找。

Javascript is hard, and jQuery makes it easy to get started. Once people learn jQuery, they will be familiar with Javascript enough to learn the other frameworks or create their own minimilistic ones. But alas you could learn something else instead, but generally the learning curve is bigger.

Javascript很难,jQuery让它很容易上手。一旦人们学习了jQuery,他们就会熟悉Javascript,足以学习其他框架或创建自己的小框架。但是唉,你可以学到别的东西,但通常学习曲线更大。

Some other really popular ones are MooTools and SproutCore - both of which have HUGE backing. jQuery is kinda like training wheels for javascript, MooTools is OO all the way, and SproutCore is for desktop apps in the cloud. Just like any programming language or framework, you learn the easiest one to get started, then as you get better you realise that different languages and frameworks are better for different things - or at least you should realise that ;-) hehe.

其他一些非常受欢迎的是MooTools和SproutCore--两者都有巨大的支持。 jQuery有点像javascript的训练轮,MooTools一直都是OO,SproutCore适用于云中的桌面应用程序。就像任何编程语言或框架一样,你学习最简单的开始,然后随着你的进步,你会发现不同的语言和框架对于不同的东西更好 - 或者至少你应该意识到这一点;-)呵呵。

#1


3  

I think jQuery can't replace JavaScript for a very obvious reason. It's because jQuery doesn't solve a single problem in JavaScript - the language. It only solves problems with inconsistent DOM implementations between browsers which is its biggest strength and it comes with some syntactical sugar.

我认为jQuery无法取代JavaScript,原因很明显。这是因为jQuery无法解决JavaScript中的单个问题 - 语言。它只解决了浏览器之间不一致的DOM实现的问题,这是它最大的优势,并且带有一些语法糖。

jQuery can't also replace the DOM APIs for another obvious reason. jQuery - the library, is controlled by one organization and primarily one man. DOM, on the other hand, is a spec that is implemented by tons of vendors while jQuery is merely a wrapper around the various implementations of that spec.

另一个显而易见的原因是jQuery也无法替换DOM API。 jQuery - 图书馆,由一个组织控制,主要由一个人控制。另一方面,DOM是由大量供应商实现的规范,而jQuery仅仅是该规范的各种实现的包装。

If jQuery were to replace these DOM APIs, then it will have to be a spec because different browser vendors can't just take its code and shove it in somewhere and make everything work nicely. The browser engine might be in C, C++, Java, or GolfScript so it becomes absolutely necessary for it to be a spec rather than an implementation.

如果jQuery要替换这些DOM API,那么它必须是一个规范,因为不同的浏览器供应商不能只是把它的代码拿到某个地方并使一切工作得很好。浏览器引擎可能是C,C ++,Java或GolfScript,因此它绝对有必要成为规范而不是实现。

Once jQuery API's become the de-facto standard and gets laid out in a spec, it will face the same problem that the specs face now. You can't just be a core-committer who fixes a problem overnight and releases a new version say 1.4.3 of the spec. The spec has be discussed, agreed upon, changed, released, and all implementors have to update their codebase to comply which makes the entire process slower. It also loses the ability to fix cross-browser quirks because it doesn't get to control that since its operating at a higher level in the food chain.

一旦jQuery API成为事实上的标准并在规范中得到规划,它将面临规范现在面临的同样问题。你不能只是一个在一夜之间解决问题的核心提交者,并发布一个新的版本说1.4.3的规范。规范已经讨论,同意,更改,发布,并且所有实现者都必须更新其代码库以符合这一要求,这会使整个过程变慢。它也失去了修复跨浏览器怪癖的能力,因为它无法控制它,因为它在食物链中的更高层次上运作。

Then, because of it being a spec and moving slowly, you can always come up with your own library *Query that simplifies the spec APIs even further, fixes cross-browser issues, and move at a much faster pace.

然后,由于它是一个规范并且移动缓慢,您可以随时提出自己的库*查询,进一步简化规范API,修复跨浏览器问题,并以更快的速度移动。

This is why jQuery can't replace the DOM API because if it does, it will stagnate rather quickly as better, more innovative, and competing abstractions spring up every single day.

这就是为什么jQuery不能取代DOM API的原因,因为如果它确实如此,它会停滞不前,因为每天都会出现更好,更具创新性和竞争性的抽象。

#2


22  

No, jQuery does not replace JavaScript, because it is JavaScript. But it helps you a lot, especially in selecting elements and applying functions on elements.

不,jQuery不会取代JavaScript,因为它是JavaScript。但它对你有很大的帮助,特别是在选择元素和在元素上应用函数时。

The probably most important argument for using jQuery: You don't have to think about cross-browser compatibility.
Seriously, the different JavaScript implementations in the browsers are driving me crazy.

使用jQuery可能是最重要的论点:您不必考虑跨浏览器兼容性。说真的,浏览器中不同的JavaScript实现让我发疯。

But I also don't think jQuery should be used for everything. It depends on where (e.g. which browsers) the JavaScript is used and what you actually do.

但我也不认为jQuery应该用于所有事情。这取决于JavaScript的使用位置(例如,哪些浏览器)以及您实际执行的操作。

And as I already answered on other question, you can only master jQuery if you understand JavaScript. It is very easy to write bad jQuery code if you don't understand how it works.

正如我已经在其他问题上回答的那样,如果你理解JavaScript,你只能掌握jQuery。如果您不了解它的工作方式,那么编写糟糕的jQuery代码非常容易。

Update:

In fact in modern browsers you can already do stuff you normally used jQuery for, like using selectors or each(), natively in JavaScript, with document.querySelectorAll() and the array method forEach().
But this is the problem: In modern browsers. jQuery ensures that you can use the same API and don't have to care about the browser version.

事实上,在现代浏览器中,您已经可以使用通常使用jQuery的东西,例如使用selectors或者每个(),本地使用JavaScript,使用document.querySelectorAll()和数组方法forEach()。但这就是问题:在现代浏览器中。 jQuery确保您可以使用相同的API,而不必关心浏览器版本。

#3


19  

I sort of have a bias against jQuery. It's my only ignored tag :)...

我对jQuery有偏见。这是我唯一被忽略的标签:)...

In my opinion, it is inappropriate for people to post into other questions saying "Can I haz jQueries?" when the other person is into "plain" JavaScript, though.

在我看来,人们不宜在其他问题上发帖说“我能不能jJeries?”但是,当另一个人进入“普通”JavaScript时。

I believe that everyone should learn "plain" javascript+dom manipulation BEFORE going into jQuery, sort of like how you shouldn't jump straight into DirectX when you learn c++; you can't work with jQuery without JavaScript know-how...

我相信每个人都应该在进入jQuery之前学习“简单的”javascript + dom操作,有点像你学习c ++时不应该直接跳到DirectX;没有JavaScript专有技术,你无法使用jQuery ...

In the end, though, you should use what you feel more comfortable with.

但最后,你应该使用你觉得更舒服的东西。

But in all honesty, I believe that you will have more opportunities if you also become proficient at JavaScript, and let's say jQuery does die out one day... Your experience with JavaScript itself will still be there.

但老实说,如果你也熟练掌握JavaScript,我相信你会有更多的机会,让我们说jQuery有一天会消失......你对JavaScript本身的体验仍然存在。

#4


4  

As I see it, JavaScript is ugly, error prone and a pain. I love the flexibility that allows for approaches such as jQuery, prototype.js, etc. However, the emergence of these libraries proves my point. Not all of this is JavaScript's fault. Some of it is due to the web browsers.

正如我所看到的,JavaScript是丑陋的,容易出错并且很痛苦。我喜欢允许jQuery,prototype.js等方法的灵活性。但是,这些库的出现证明了我的观点。并非所有这些都是JavaScript的错。其中一些是由于网络浏览器。

To better answer the actual question:

为了更好地回答实际问题:

jQuery just makes things easier, like any good library/framework should. This is the reason it gets suggested so much. It's just easier to do it in jQuery than plain JavaScript. Trying to explain all the minutiae to get plain JavaScript to work in a variety of situations can be a serious pain.

jQuery只是让事情变得更容易,就像任何好的库/框架一样。这就是它得到如此多建议的原因。在jQuery中执行它比在纯JavaScript中更容易。试图解释所有细节以使普通JavaScript在各种情况下工作可能是一个严重的痛苦。

That said, I agree. If someone is looking for just a JavaScript solution, that is what they should get. However, they should realize that it could be a difficult process and not everyone has the time/interest to go to that much trouble.

那就是说,我同意。如果有人正在寻找一个JavaScript解决方案,那就是他们应该得到的。然而,他们应该意识到这可能是一个艰难的过程,并不是每个人都有时间/兴趣去解决那么多麻烦。

#5


3  

Well I can't speak for everyone but jquery just makes javascript tasks easier. Not to mention that they are tested across multiple browsers so less concern with cross-compliant issues.

好吧,我不能代表所有人,但jquery只是让javascript任务更容易。更不用说它们在多个浏览器中进行测试,因此不太关心交叉兼容问题。

What you could write in 1 line of jquery could take you 10 or more with writing your own javascript. Also the benefit of using the library is that it has been tested for bugs that you don't have to worry about.

你可以用1行jquery写的东西可以带你10个或更多写自己的javascript。使用该库的好处是它已经过测试,您不必担心它们的错误。

Just my opinion.

只是我的观点。

#6


2  

Is jQuery replacing JavaScript as a whole?

jQuery是否取代了JavaScript作为一个整体?

The only thing I never saw addressed in this thread was this: jQuery cannot replace Javascript,,, it is Javascript. It's nothing more than a collection of pre-written functions in Javascript that takes care of a lot of commonly-used and desired requirements of many developers.

我从未在这个帖子中看到过的唯一一件事是:jQuery无法取代Javascript ,,,它是Javascript。它只不过是Javascript中预先编写的函数集合,它可以处理许多开发人员常用的和期望的需求。

Lets say you've always made your own paper (chop the wood, pulp it, dry it, decorate it, etc) before making your very special paper cut-outs. One day, while making paper cut-outs from your homemade paper, someone points out to you the wonders of pre-made paper (Oh happy day), and says "no need to make your own... get right to the fun of making paper cut-outs." You've never used pre-made paper... to you, paper is the result of a lot of time spent working with wood. So... now that you've discovered Acme Paper, would you ask if Acme Paper has replaced wood? Of course not... it's made from wood. Instead, you would suddenly think of Acme Paper as a time-saver, as a way to get to the final result of making cut-outs without all that wood-working hassle to make the paper itself.

可以说,在制作非常特殊的纸张切口之前,你总是制作自己的纸张(砍木头,纸浆,干燥,装饰等)。有一天,在用自制纸张制作剪纸的同时,有人向你指出预制纸张的奇迹(哦,快乐的一天),并说“不需要自己制作纸张......”制作剪纸。“你从来没有使用预制纸......对你而言,纸张是花在木头上的大量时间的结果。那么......既然你已经发现了Acme Paper,你会问Acme Paper是否已经取代了木材?当然不是......它是用木头做的。相反,你会突然想起Acme Paper作为一个节省时间的方法,作为一种方法来达到制作切口的最终结果,而没有任何木工工作的麻烦来制作纸张本身。

Likewise, jQuery (the 'brand-name' paper) doesn't replace the Javascript (wood) from which it was made, it just saves you the hassle of making your own utility functions (paper) before you get to the fun of making your own custom code (little paper cutouts).

同样,jQuery('品牌'纸)不会取代制作它的Javascript(木头),它只是让你省去制作自己的实用功能(纸张)的麻烦,然后才能获得制作的乐趣你自己的自定义代码(小纸剪纸)。

Have I confused the issue yet?

我把这个问题弄糊涂了吗?

Cheers!

#7


2  

I can't speak for the bias toward a particular framework, but usually using a framework trumps vanilla javascript when it comes to getting things done, and done right. David Walsh said it best here:

我不能代表对特定框架的偏见,但通常使用框架胜过vanilla javascript来完成工作,并且做得对。大卫沃尔什在这里说得最好:

http://davidwalsh.name/6-reasons-to-use-javascript-libraries-frameworks

#8


1  

If you're just using JavaScript to manipulate the DOM and do AJAX, why not use a framework to do the heavy lifting and grunt work?

如果您只是使用JavaScript来操作DOM并执行AJAX,那么为什么不使用框架来完成繁重的工作呢?

JavaScript does extend beyond web pages and the DOM too. See node.js for some serious awesomeness. For a small peek read this blog post (though it is more impressive with more people on at once).

JavaScript确实扩展到了网页和DOM之外。请参阅node.js以获得一些非常棒的功能。对于一个小小的偷看,请阅读这篇博客文章(尽管一次有更多人参与其中更令人印象深刻)。

#9


1  

It's the same thing as asking why there is a preference towards using any framework such as MVC .net, CakePHP etc. Speed, flexibility, reuse etc.

这与询问为什么偏好使用任何框架(如MVC .net,CakePHP等)的速度,灵活性,重用等等是一回事。

However, although frameworks do a whole bunch of cool stuff, in the end it doesn't replace the need to know and understand underlying language.

然而,虽然框架做了很多很酷的东西,但最终它并没有取代了解和理解底层语言的需要。

#10


1  

To me, jQuery is sort of like Cocoa for the Mac. I have read that the Cocoa framework is composed simply of many "low-level" Unix commands that are the base of the Mac OS. So when you do something as simple as allocating memory, these long-lost simple commands are run.

对我来说,jQuery有点像Mac的Cocoa。我已经读过Cocoa框架只是由许多“低级”Unix命令组成,这些命令是Mac OS的基础。因此,当您执行像分配内存这样简单的操作时,会运行这些长期丢失的简单命令。

I would not be surprised if the progression from Unix to Cocoa were to happen to Javascript into jQuery — after all, it would be easier to call a jQuery command that internally did 10 basic Javascript actions (especially if the command was commonly used). Personally, I am against it, because it limits the freedom of the developer. While others might argue it allows more creativity because it's easier/faster to build new/better things, people will rely on it, and eventually become dependent, and forget all about the basic core of Javascript.

如果从Unix到Cocoa的进展发生在Javascript到jQuery中,我不会感到惊讶 - 毕竟,调用一个内部执行10个基本Javascript操作的jQuery命令会更容易(特别是如果命令是常用的话)。就个人而言,我反对它,因为它限制了开发人员的*。虽然其他人可能认为它允许更多的创造力,因为它更容易/更快地构建新的/更好的东西,人们将依赖它,并最终变得依赖,并忘记了所有关于Javascript的基本核心。

What if a specific "handy-dandy, pre-made and ready-to-use" function for what you wanted didn't exist in the merry "simple" world of jQuery? If developers relied on jQuery, they'd be at a total loss. In my opinion, we developers must continue to be independent and create our own code, though using a little pre-made stuff doesn't hurt either.

如果在jQuery的快乐“简单”世界中不存在特定的“方便花哨,预先制作且随时可用”的功能,那该怎么办?如果开发人员依赖于jQuery,他们将完全失败。在我看来,我们开发人员必须继续保持独立并创建我们自己的代码,尽管使用一些预先制作的东西也不会造成伤害。

#11


1  

A following says a lot about an API or Framework. In general, more users will tend to generate better documentation. Documentation can go a long way in the adoption process.

以下是关于API或框架的很多内容。通常,更多用户倾向于生成更好的文档。文档可以在采用过程中发挥很大作用。

jQuery does have its limitations, at least at the time of the writing of this answer. For example, today I wanted to test functionality with a xhr that stays at readystate 3 most of the time. I decided I might be better off writing my own jQuery plugin instead of using the $.ajax that is commonly used. That wouldn't have been such a bad thing. However, I've come to appreciate that jQuery is tested on many versions of many different browsers. I can hit a target usability audience just by using one framework.

jQuery确实有它的局限性,至少在写这个答案的时候。例如,今天我想用大多数时间保持在readystate 3的xhr来测试功能。我决定编写自己的jQuery插件,而不是使用常用的$ .ajax。这不会是一件坏事。但是,我开始意识到jQuery已经在许多不同浏览器的许多版本上进行了测试。我只需使用一个框架即可达到目标可用性受众。

In the end, I could have experimented with $.ajax beforeSend to see if there was a way to attach a handler for readystate 3, but the documentation I was reading led me to believe that it would have been more work for the task I needed to accomplish.

最后,我可以尝试使用$ .ajax beforeSend来查看是否有一种方法可以为readystate 3附加一个处理程序,但是我正在阅读的文档让我相信这对我需要的任务来说会更有用。去完成。

Overall, I have to say that I've enjoyed jQuery more than the other frameworks I've tried. When something else comes along, I'll give it a try also.

总的来说,我不得不说我比我尝试过的其他框架更喜欢jQuery。当其他东西出现时,我也会尝试一下。

#12


1  

I've noticed the same thing lately. That jQuery - but take any other framework - destroys analytical thinking. Developers look at browser scripting as Duplo Lego when it's in fact Technics.

我最近注意到了同样的事情。那个jQuery - 但是采取任何其他框架 - 破坏了分析思维。开发人员将浏览器脚本视为Duplo Lego,而实际上是Technics。

jQuery, while an excellent tool for UI manipulation - doesn't cover every aspect of high level JS programming. What about data, for instance? jQuery is quite poor in that area, but still, when a problem arises that has something to do with sorting or filtering - we go instantly into searching for a jQuery plugin.

jQuery虽然是用于UI操作的优秀工具,但并未涵盖高级JS编程的各个方面。例如,数据怎么样? jQuery在这个领域相当糟糕,但是当出现与排序或过滤有关的问题时,我们会立即去寻找一个jQuery插件。

jQuery will not, can not replace JS as a whole.

jQuery不会,不能替代JS作为一个整体。

#13


0  

jQuery has become a defacto standard, the way that C or Java is for the desktop programming world - everyone knows it, or should as it provides common language. Typically everyone starts on jQuery and then learns about Javascript from their experiences and can look elsewhere.

jQuery已成为事实上的标准,C或Java用于桌面编程世界的方式 - 每个人都知道,或者应该提供通用语言。通常每个人都从jQuery开始,然后从他们的经验中学习Javascript,并可以在其他地方查找。

Javascript is hard, and jQuery makes it easy to get started. Once people learn jQuery, they will be familiar with Javascript enough to learn the other frameworks or create their own minimilistic ones. But alas you could learn something else instead, but generally the learning curve is bigger.

Javascript很难,jQuery让它很容易上手。一旦人们学习了jQuery,他们就会熟悉Javascript,足以学习其他框架或创建自己的小框架。但是唉,你可以学到别的东西,但通常学习曲线更大。

Some other really popular ones are MooTools and SproutCore - both of which have HUGE backing. jQuery is kinda like training wheels for javascript, MooTools is OO all the way, and SproutCore is for desktop apps in the cloud. Just like any programming language or framework, you learn the easiest one to get started, then as you get better you realise that different languages and frameworks are better for different things - or at least you should realise that ;-) hehe.

其他一些非常受欢迎的是MooTools和SproutCore--两者都有巨大的支持。 jQuery有点像javascript的训练轮,MooTools一直都是OO,SproutCore适用于云中的桌面应用程序。就像任何编程语言或框架一样,你学习最简单的开始,然后随着你的进步,你会发现不同的语言和框架对于不同的东西更好 - 或者至少你应该意识到这一点;-)呵呵。