|
|
|
|
|
by interlocutor
2656 days ago
|
|
The best advertisement for jQuery, ironically, is this site: http://youmightnotneedjquery.com/ Look at how simple things are in the left column, and how much more code is needed in the right column. jQuery has many convenience features such as chaining, for example: item.addClass('selected').siblings().removeClass('selected'); and you don't have to check for nulls after each selection. Many functions such as closest() and remove() have no equivalents in IE11, and other things such as replaceWith() and before() are not available even in Edge. For simple sites it is easy enough to remove jQuery, but for more complex javascript applications, especially apps that have a lot of interactivity, removing jQuery will result in more code, or you will end up writing a lot of utility functions thereby creating your own little clone of jQuery. |
|
A modern version of youmightnotneedquery with, say, features currently supported by 90%+ browsershare would be even more concise. The AJAX JSON request in the first example, for example, is just:
The Request example is: The fadeIn example is (CSS3, not JS): (It gets even easier if you're fading in on hover or other user action, because you can use a CSS transition instead of the animation and then just use .classList.add()).)