Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5843417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:09:06+00:00 2026-05-22T12:09:06+00:00

I have often heard that jQuery has made some poor API decisions. Although jQuery

  • 0

I have often heard that jQuery has made some poor API decisions. Although jQuery is not my favourite library it’s the library I’ve used most often and I find it hard to point out specific mistakes in the API design or how it could have been improved.

What parts of jQuery’s API could have been done better, how could it have been implemented different and why would that different implementation be better?

The question extends to both low level individual details of the API and high level details of the API. We are only talking about flaws in the API rather then flaws in the high level design / purpose of the library, jQuery is still a DOM manipulation library centred around a selector engine.

Because of the necessity of API freezing in popular libraries, jQuery is stuck in it’s current state and the developers are doing a great job. As can be seen by the recent .attr vs .prop change the developers do not have the flexibility to change any of their design decisions (which is a shame!).

One specific example I can think of would be

$.each(function(key, val) { })

vs

$.grep(function(val, key) { })

which is confusing enough that I have to double check what the parameters are frequently.

Please do not compare the jQuery library to full fledged frameworks like dojo and YUI and complain about lack of features.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:09:07+00:00Added an answer on May 22, 2026 at 12:09 pm
    • .load() is overloaded with entirely different behavior depending on the arguments passed

    • .toggle() is overloaded with entirely different behavior depending on the arguments passed

    • too much overloading of the jQuery() function perhaps.

    • the .attr() you mentioned. The distinction from properties should have been immediate IMO.

    • .map( key,val ) but $.map( val,key ), and the this values are different.

    • non-standard selectors ought to have been kept out of Sizzle IMO. Javascript based selector engines should become obsolete in a number of years, and people hooked on the proprietary selectors will have a more difficult transition

    • poor method naming of methods like .closest() or .live(). What exactly do they do?

    • I recently discovered that you can’t set the standard width and height attributes via the props argument when creating a new element. jQuery runs its own width and height methods instead. IMO, the spec attributes should have been given priority, especially since width and height can be set via css.

    $('<img/>', { 
        css:{width:100, height:100},
        width:100, // <-- calls method, why?
        height:100, // <-- calls method, why?
    });
    
    • $.get() and .get() are entirely different.

    • .get() and .toArray() are identical when passing no arguments

    • toArray() and $.makeArray() do effectively the same thing. Why didn’t they give them the same name like .each() and $.each()?

    • two different event delegation methods. .delegate() the sensible one, and .live() the magical “wow, it just works!” one.

    • .index() is overloaded with 3 behaviors, but their differences can be confusing

     // v---get index   v---from collection (siblings is implied)
    $('selector').index();
     // v---from collection   v---get index
    $('selector').index(element);
     // v---get index      v---from collection
    $('selector').index('selector');
    

    The first one is understandable if you remember that it only operates on the first element

    The second one makes the most sense since jQuery methods usually operate on an entire collection.

    The third one is entirely confusing. The method gives no indication of which selector is the collection and which selector represents the element whose index you want from the collection.

    Why not just eliminate the third one, and have people use the second one like this:

     // v---from collection      v---get index
    $('selector').index( $('selector') );
    

    This way it fits more closely with the rest of jQuery where .index() operates on the entire collection.

    Or at least reverse the meaning of the selectors to fit in better:

     // v---from collection   v---get index
    $('selector').index('selector');
    

    Here’s another to think about anyway.

    I have some concerns with jQuery’s event handling/data storage system. It is praised because it doesn’t add functions to on[event] properties that can close around other elements, creating memory leaks in IE. Instead it places a lightweight expando property, which maps to an entry in jQuery.cache, which holds handlers and other data.

    I believe it then attaches a handler with in turn invokes the handler that you assigned. Or something like that.

    Whatever the system is doesn’t really matter. The point is that the connection between the element(s) and the jQuery.cache is that expando.

    Why is that a big deal? Well philosophically jQuery is not a framework; it is a library. It would seem that as a library you should be able to use or not use the jQuery functions without concern for negative effects. Yet if you go outside jQuery when removing elements from the DOM, you’ve orphaned any handlers and other data associated with those elements via the expando, creating a nice and fully cross-browser memory leak.

    So for example, something as simple as el.innerHTML = '' could be very dangerous.

    Couple this with the jQuery.noConflict() feature. This enables developers to use jQuery with other libraries that utilize the $ global namespace. Well what if one of those libraries deletes some elements? Same problem. I have a feeling that the developer that needs to use a library like Prototypejs along side jQuery probably doesn’t know enough JavaScript to make good design decisions, and will be subject to such a problem as I’ve described.


    In terms of improvements within the intended philosophy of the library, as far as I know, their philosophy is “Do more, write less” or something. I think they accomplish that very well. You can write some very concise yet expressive code that will do an enormous amount of work.

    While this is very good, in a way I think of it as something of a negative. You can do so much, so easily, it is very easy for beginners to write some very bad code. It would be good I think if there was a “developer build” that logged warnings of misuse of the library.

    A common example is running a selector in a loop. DOM selection is very easy to do, that it seems like you can just run a selector every time you need an element, even if you just ran that selector. An improvement I think would be for the jQuery() function to log repeated uses of a selector, and give a console note that a selector can be cached.

    Because jQuery is so dominant, I think it would be good if they not only made it easy to be a JavaScript/DOM programmer, but also helped you be a better one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have often heard that using break s in Java is considered bad practice,
jQuery plugins often have dependencies on external files: jQuery library, style sheets (CSS), images,
I have often heard that C can crash spectacularly. Recently I got my first
I have often heard that numerically increasing numbers make good ids for static data
I have often heard this term being used, but I have never really understood
I have often heard people talking about hashing and hash maps and hash tables.
I've often heard the argument (in javascript, but many languages have an eval-like feature)
I have often wondered why it is that non-English speaking programmers are forced to
I have often PATHs for files which do not exist in my codes. I
I have heard that the ARCHOS 5 Internet Tablet doesn't have the Google APIs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.