10th Anniversary of JQuery
ejohn.org
ejohn.org
http://yuiblog.com/blog/2006/02/13/the-yahoo-user-interface-...
(I too am old enough to remember the internet before the web. You really had to work hard to goof off at work when all you had was nntp, archie and gopher.)
Nonsense, I could goof off quite easily with nntp :)
And I still miss the spinning globe.
Here's a whole list just for click, which is probably the most standardized event handler, and doesn't even go back before the IE5.5 era:
The other thing it did well was change the thinking about how JavaScript should interact with the DOM. In the past you'd have libraries that made DOM access easier, but they largely followed the same conventions as the underling APIs. jQuery broke from that and completely re-envisioned the API layer. The underlying APIs were treated as an implementation detail; this approach is something that subsequent libraries have adopted too.
jQuery was a huge timesaver, as was dojo, mootools, prototype, etc and not having at least one of these libraries would have sucked. And although jQuery "won" it could have easily been any other javascript library.
Even if these libraries somehow didn't exist, there was tons of cross-browser snippets plastered across the web that dealt with most of the common problems (ajax, event listeners, etc).
Prototype first came out in Feb 2005. Dojo 0.1 was Aug 2005, and 1.0 (first stable, after a total rewrite) was Nov 2007.
I do remember using Prototype with script.aculo.us and thinking it was pretty neat to add some effects to my server-side-created web apps, but that they'd largely stay server side. The first time I saw jQuery, that was when I thought "Yeah, okay, we can actually start building some serious client-side interactions here" instead of just server-generated HTML pages.
jQuery took me from hating (but tolerating) javascript to actually enjoying client-side web development.
jQuery is pretty much the only library or framework made 10+ years ago I can use and still feel like "this is actually well-designed". Frameworks generally obviate the need for it, but if a framework isn't an option and if I'm going to be writing more than 100 lines of code (otherwise I'd suck it up and use plain JS), I always still use jQuery.
It is currently my 3rd most endorsed linkedin skill after 'dressing himself' and 'marking recruiters as spam'. My friends suck.
</spam>
https://www.manning.com/books/secrets-of-the-javascript-ninj...
Why wouldn't the HTML standards committees follow the trend and improve the API?
Edit: removed 'chainable' as a descriptor of jQuery's API as I didn't mean to focus on it; was simply just calling its API chainable but it's led to confusion.
The things that keep jquery alive and well in mind are:
* A convenient way to add to the DOM. While SELECTING elements has gotten way better than the Bad Old Days, ADDING elements is still painful. (one element isn't bad, but if you're trying to add, say, a UL with a number of LI elements, it's...tedious.)
* A good wrapper for Ajax calls. Not that there aren't better, but jquery has a perfectly good one. Heck, I've jqueryified a page to test calls I'm making outside of jquery because doing a call via console is...tedious.
* Promises. We'll soon have them native (and better), but for a long time jquery has been super convenient for this.
https://developer.mozilla.org/en/docs/Web/API/Fetch_API
if you ask me, it's impressively well designed. it looks so boring and straight forward yet somehow nearly all "simple" http libraries (not to mention builtins) in nearly all popular languages are more convoluted.
jQuery's API is chainable; that's all I meant by it. Their API overall just simplifies everything. I'd like to see the standards committees take ideas from development trends and work to simplify the DOM API.
Honestly as far as AJAX goes I really think HTTP needs to be put into the JavaScript standard itself; not just the HTML standards. It's hard finding good libraries that can make HTTP calls in the exact same way in both the browser and node (which is important to me because much of my library type code can run in either environment). I had to write this myself and while my implementation is limited it makes my life easier.
Careful with that axe... Before jQuery 3.0, its promises API is not compatible with the Promises/A+ spec: http://stackoverflow.com/q/23744612/1233508
If you're used to jQuery's promises, you can be in for a few surprises when trying to use other libraries (or even when updating to jQuery 3).
As for the chainable syntax, I'm honestly in two minds about it. It's incredibly powerful, but some of the worst JS I've ever seen has been written in endless jQuery chain statements.
https://learn.jquery.com/events/handling-events/#binding-eve...
This isn't true. If you're only talking about jQuery then fine, it has a performance hit to its usage but it's not that big of a deal. But React, Angular and some of the frameworks out there? They abstract a lot more away from the DOM and can cause some serious performance issues (even if you're not careless they all incur a performance hit which can be noticeable in mobile web browsers if you're not careful).
Many have had to rewrite portions (or entire) web applications when they hit certain scale and use far more native DOM APIs than before just to get the necessary performance. Atom is one example but there are plenty more.
So no improvements to the DOM API are not unnecessary; in fact I think they are a bit necessary. You wouldn't have nearly as many people abstracting away from it if it were far more approachable and there is nothing wrong with making it easier to use.
For me I'd need to do some research to create a good, comprehensive list but some of the things off the top of my head:
- Simplified ways for creating HTML elements. jQuery's way is nice and I think chainable, while a double edge sword in some cases, can make this a little nicer (doesn't have to be chainable to the extent that I can make 10 elements in one line but being able to set the properties in the creation step would be nice). In fact even allowing a simple JS Object to be used for setting properties in the creation step would be handy.
- Templating needs to be built in. Practically every single framework has its own way of templating and they all suck to a degree because you have to take the huge tradeoff of either doing the templating server-side, loading the HTML then replacing the values or loading the JS then generating the HTML. All of it is slow. A browser native solution could be orders of magnitude faster than dealing with the last two and makes it easier to leave the front end as purely static versus having some dynamically generated items.
- HTML and ECMAScript committees needs to get together and create clear separations of functionality between what the HTML and the ECMAScript standards provide. AJAX was great but this is an HTML standard; HTTP needs to be baked directly into the ECMAScript standard since JavaScript can run anywhere now. Eventing too needs to be moved from HTML standards (as far as the eventing itself is described; the events individual elements use most certainly should stay in the HTML standards) and build eventing right into ECMAScript. Right now node and the browser both provide their own event handling.
Obviously those items are far more nuanced than my real fast list but you asked me to give you answers to a hard problem :). I could make them far more detailed and nuanced with some time and research (I have other ideas but I need to investigate them more).
http://ejohn.org/blog/annotated-version-of-the-original-jque...
I'm still waiting to meet John in real life and thank him out loud for jQuery. One of these days.
a) smoothed over differences between browsers. With the web being taken more seriously by everyone, the browser implementers are much more careful about all following the same standard so with every year that goes by there are fewer cross browser quirks to worry about (it's still a major pain today though)
b) providing convenience methods for manipulating the dom and working with data etc. I think jQuery has less of a role to play since ES5 and ES6 are how javascript is written nowadays and have more advanced features than js did in jquery's heyday. Also, for advanced client side apps, frameworks like angular and ember also provide such features.
I think once web apps starting getting larger and larger, jQuery became more and more of a hinderance (since it offered no framework for structuring apps).
Had the world gone with one of the many other options back in the day, I think we might be in a better place already.
It would help if you told us what insight we missed about MooTools that would have made the world a better place? Why jQuery has made it such a miserable one?
MooTools and other libraries might possibly be more powerful if you are developing in Javascript in general, but for web development I primarily care about DOM manipulation, and it was much easier to pick up jQuery than anything else at the time. It's a mistake to think that languages should win out simply based on functionality and capabilities, without taking into account things like ease of use and learning curve.
ES7 wanted to introduce an Array#contains method. But due to prototype extension issues like https://esdiscuss.org/topic/having-a-non-enumerable-array-pr... , they had to rename it to Array#includes ...
document.getElementById(id)
vs.
$('#' + id)
Let's not forget the lack of chainability in DOM element method calls:
el = document.getElementById(id)
el.method1()
el.method2()
vs.
$('#' + id).method1().method2()
Yes--to me at least--conciseness and elegance matter, now more than ever. A better DOM API does not mean the end of jQuery. In a similar vein, ES6 does not spell the end for CoffeeScript.
b) jQuery was necessary for a long time to have (efficent) fun with the DOM (i.e.: my contribution http://www.fullstackoptimization.com/box2d-jquery/ )
c) Damn, I'm glad that the days of jQuery necessity are (nearly) over. It's a ghetto.
There was a guy there that John Resig had shown jQuery to the night before, and the guy was just raving about it. And when John showed off jQuery, it just was damn impressive.
Wish I could remember more, its a bit of a hazy memory now! :)
:)
I think that it's hard to truly appreciate jQuery unless you were actually attempting to write code for web applications that dealt with a lot of JavaScript at the time. 2005 and 2006 was a nightmare for writing front-end behavior on web-based applications.
This wasn't because JS was particularly awful to write code in. Internet Explorer, the king of browsers at the time, routinely exhibited totally unexpected behavior with little to no tools to discover how to fix things. While this may sound like a personal attack against Internet Explorer, it's the truth of the matter. Other browsers had quirks, but none were as important as the quirks discovered in the most popular browser at the time.
The things that you wanted to start doing to make your app "Web 2.0" like transitions, CSS animations, AJAX behavior, big DOM manipulations, and so on, were totally possible with JS. You just had to write a lot of it and pray to whoever you wanted when you went to test it in IE.
One of the big catalysts for getting something better than vanilla JS to play with wasn't just to make writing the code more pleasurable, it was to make it easier to GSD. Two camps came out in this regard. You had folks who were abstracting away the JS a lot more, creating more of their own syntax and language for everything; a framework built in JS. Then there were folks like jQuery who were creating what a lot of people considered a library, in that it felt like you were utilizing a lot of the same vanilla JS you knew and loved, but with some wrappers and helpers.
I mean, AJAX was a big and cool "aha" moment when you first saw it and played with it. But the first time you got to do things like:
* Identify an element without verbosity like document.getElementById()
* Attach an onclick to elements reliably and in a cross-browser safe way
* Change the color, replace some text, and fade in or shake or whatever was cool at the time in a single line of code that worked everywhere
... things like these were also very, very cool.
And because jQuery was well-documented, and didn't change the language and feeling of using a lot of JavaScript too tremendously, it was, and continues to be, an invaluable tool in so many belts. There are tons of good libraries built on top of jQuery that continue to evolve with standards and trends.
Overall it's stood the test of time well, and has saved countless hours of development time; two important qualities in great software.
I might be missing something. I used to use it for animations and manipulating DOM, but there are decent lighter alternatives now.
Till 2011 I had to use a framework that was a bit like GWT in PHP, because the company just had PHP and C coders and no one wanted to pay a switch.
2011 I started with JS and read stuff like "The Good Parts" and "Professional JavaScript". I wrote a JSON-HTTP-API and rewrote the whole UI in ExtJS.
Then I took a sabbatical in 2014 where I played around with Crafty, Phaser, D3 and continued my masters degree where I had to use Ember for a few projects.
Last year I dropped in a young project that was using React.
Funny thing is, all the time JQuery felt really old to me, so I never considered using it.
Maybe I should have been clearer?
I never called its API "personally" ;)