开发者

What are pros and cons when choosing jquery as my primary javascript library? [closed]

As it currently stands, this question is not开发者_如何学JAVA a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I have started a new web application and have decided to use jquery as my primary javascript library... But still i want to get some pros and cons tips from SO users who used jquery ...


Pro's

  • Eliminates a lot of cross browser javascript issues
  • Can perform complicated Javascript operations in little code
  • Can easily add Ajax functionality to app
  • Has built in UI and effects libraries

Con's

  • Overhead of adding extra javascript to page
  • Learning curve may not be short for some developers


All pros, no cons.

The only thing will be the execution time overhead that jQuery adds to load its files and execute its functions, but compared to the Pro of coding cross browser compatible JavaScript it is nothing.

Also compared to other JavaScript libraries jQuery is one of the fastest and smallest out there. Their community is huge and you can easily find support and good documentation.


Pros:

  • Large community
  • Useful for selecting and iterating over sets of DOM nodes
  • Eliminates some inconsistencies between browsers
  • Makes it easy for inexperienced JavaScript developers to do relatively complex scripting tasks

Cons:

  • Regular updates that change existing behaviour
  • Some confusing fundamental API methods (e.g. attr() method: what exactly does it do? It certainly blurs the line between attributes and properties)
  • Encourages "chaining", which leads to code that is difficult to debug: in a long chain of jQuery method calls, there's nowhere to put logging statements, so you need a full-on debugger
  • Short list of supported browsers
  • A general point about general purpose libraries: they encourage developers not to attempt to understand the underlying problems that the libraries try to solve, leading to a tendency to think of the library as being magical and to use it for absolutely everything
  • Adds 70K of JavaScript to every page where it's used when often a few bytes of non-jQuery code would do
  • Performance is generally much slower than the equivalent (well thought-through) non-jQuery code
  • Quality of plug-ins is very variable


You've made a good choice, don't worry. jQuery is a very well designed library - it is powerful, clean, well documented, and extremely popular. Learn it well, and it will be a powerful tool in your arsenal.

That said, I think that to be really aware of its pros and cons versus other frameworks, you should first learn it well. Only a deeper understanding of a tool enables you real comparison with other tools.


The only con I can think of is the occasional memory leaks. It is a great framework on top of javascript and is not restrictive.

That said, jQuery UI is terrible to my taste and if your application requires highly interactive UI try Ext JS.


The pros and cons are really relative to what your new web application will be doing. If it is going to be JavaScript/Ajax-rich and requires cross-browser support then jQuery is the way to go - no doubt. However, if you are only going to use JavaScript very sparingly, then it may be over-kill to include a large-ish framework, and it would be more efficient (in terms of performance and page size) to code the JavaScript directly.


Pros: Lightweight, easy to use, good documentation, gets rid of nearly all cross-browser issues and normalizes the event model.

Cons: jQuery UI doesn't have much to offer, and the plugins are hit or miss.

If you're doing a very JavaScript-heavy Rich Internet Application, go with YUI or ExtJS. jQuery is an excellent DOM manipulation library, and is the best for highly custom UI work. But if you need lots of stock UI and a robust data management system behind it, you need a bigger framework to tie it all together.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜