JQuery VS javascript?

我最近偶然发现了一些 javascript 论坛(遗憾的是,链接在宇宙中的某个地方丢失了) ,在这些论坛上你可以感受到对 jQuery 的憎恨,因为它不是... ... 任何好的东西?

大多数争论似乎都有道理。

现在,我真的很喜欢 jQuery,主要是因为它让我专注于我想做的事情,而不是浏览器的不一致性,而且它实际上让 Ajax 变得很酷(或者说 过度使用?)效果乐趣。

但是如果 jQuery 的核心真的有问题的话,我不想用我真正依赖它的方式去依赖它。

我不想再争论哪个框架是最好的... ... 但是... ... 哪个框架是最好的 (笑话)?作为一个案例使用,考虑中小型网站和它的管理。

我只是想弄清楚,如果在 一些框架或纯 javascript 与几个矿函数真的有所不同。

编辑:

事实上,我尝试着进行一次正常的客观讨论,讨论以下问题的利弊:

  1. 在纯 javascript 和
  2. JQuery 和其他的,

因为 jQuery 似乎最容易处理最快的学习曲线。然而,有些人就是不理解它,认为我正在开始另一个火焰(我不是)。事实上,我投票决定重新讨论这个问题。

而且我真的很感兴趣:

  • JQuery 严重依赖浏览器嗅探吗? 这会是未来的一个潜在问题吗? 为什么?
  • 我发现了很多 JS 选择器引擎,有没有 AJAX 和 FX 库?
  • 除了对约翰 · 雷西格的浏览器嗅探和个人“憎恨”之外,jQuery 还有什么错误的理由吗?

JQuery 实际上和大多数使用的一样,也代表其他框架。

123033 次浏览

It's all about performance and development speed. Of course, if you are a good programmer and design something that is really tailored to your needs, you might achieve better performance than if you had used a Javascript framework. But do you have the time to do it all by yourself?

My personal opinion is that Javascript is incredibly useful and overused, but that if you really need it, a framework is the way to go.

Now comes the choice of the framework. For what benchmarks are worth, you can find one at http://ejohn.org/files/142/ . It also depends on which plugins are available and what you intend to do with them. I started using jQuery because it seemed to be maintained and well featured, even though it wasn't the fastest at that moment. I do not regret it but I didn't test anything else since then.

jQuery like any other good JavaScript frameworks supplies you with functionality independent of browser platform wrapping all the intricacies, which you may not care about or don't want to care about.

I think using a framework is better instead of using pure JavaScript and doing all the stuff from scratch, unless you usage is very limited.

I definitely recommend jQuery!

Jquery VS javascript, I am completely against the OP in this question. Comparison happens with two similar things, not in such case.

Jquery is Javascript. A javascript library to reduce vague coding, collection commonly used javascript functions which has proven to help in efficient and fast coding.

Javascript is the source, the actual scripts that browser responds to.

  • Does jQuery heavily rely on browser sniffing? Could be that potential problem in future? Why?

No - there is the $.browser method, but it's deprecated and isn't used in the core.

  • 我发现了很多JS选择器引擎,有没有AJAX和FX库?

Loads. jQuery is often chosen because it does AJAX and animations well, and is easily extensible. jQuery doesn't use it's own selector engine, it uses Sizzle, an incredibly fast selector engine.

  • Is there any reason (besides browser sniffing and personal "hate" against John Resig) why jQuery is wrong?

No - it's quick, relatively small and easy to extend.

For me personally it's nice to know that as browsers include more stuff (classlist API for example) that jQuery will update to include it, meaning that my code runs as fast as possible all the time.

Read through the source if you are interested, http://code.jquery.com/jquery-1.4.3.js - you'll see that features are added based on the best case first, and gradually backported to legacy browsers - for example, a section of the parseJSON method from 1.4.3:

return window.JSON && window.JSON.parse ?
window.JSON.parse( data ) :
(new Function("return " + data))();

As you can see, if window.JSON exists, the browser uses the native JSON parser, if not, then it avoids using eval (because otherwise minfiers won't minify this bit) and sets up a function that returns the data. This idea of assuming modern techniques first, then degrading to older methods is used throughout meaning that new browsers get to use all the whizz bang features without sacrificing legacy compatibility.

"I actually tried to had a normal objective discusssion over pros and cons of 1., using framework over pure javascript and 2., jquery vs. others, since jQuery seems to be easiest to work with with quickest learning curve."

Using any framework because you don't want to actually learn the underlying language is absolutely wrong not only for JavaScript, but for any other programming language.

"Is there any reason (besides browser sniffing and personal "hate" against John Resig) why jQuery is wrong?"

Most of the hate agains it comes from the exaggerated fanboyism which pollutes forums with "use jQuery" as an answer for every single JavaScript question and the overuse which produces code in which simple statements such as declaring a variable are done through library calls.

Nevertheless, there are also some legit technical issues such as the shared guilt in producing illegible code and overhead. Of course those two are aggravated by the lack of developer proficiency rather than the library itself.

Personally i think you should learn the hard way first. It will make you a better programmer and you will be able to solve that one of a kind issue when it comes up. After you can do it with pure JavaScript then using jQuery to speed up development is just an added bonus.

If you can do it the hard way then you can do it the easy way, it doesn't work the other way around. That applies to any programming paradigm.