Live data from Hacker News

Bling – the $ of jQuery without the jQuery

gist.github.com

31–40 of 138 posts

Re: Bling – the $ of jQuery without the jQuery

#31

I use jquery because I use bootstrap and it requires it for some features I use. I wish that someone would write a drop-in javascript replacement for jquery in the context of bootstrap.

There's zepto.js, which is supposed to be a drop-in replacement for jQuery. Not sure how it fares wrt Bootstrap, though.

Re: Bling – the $ of jQuery without the jQuery

#33
post #18

Can someone explain the new trend to not use jQuery?

In very basic terms - one of the biggest boons of jQuery were patching over browser incompatibilities. The tradeoff was an extra library being downloaded and a small performance trade-off (in certain scenarios).

In 2015 most browsers are in much better shape than they were in, say, 2007. A lot of people are mostly targeting users who use up-to-date, standards compliant browsers. They are also often targeting people who use mobiles, which are (for a couple of reasons) much more sensitive to poor JS performance than desktops, and also see a more tangible benefit from small page sizes.

Another advantage to jQuery was making complex JS operations very simple. Modern JavaScript has actually made life much easier[1], meaning that it's often only a little more work to use vanilla Javascript.

[1]: http://youmightnotneedjquery.com/

Re: Bling – the $ of jQuery without the jQuery

#34
post #23

Earlier quoted context omitted.

1) Paul Irish is a former jQuery team member and he has blog entries about how much he's learned from reading jQuery's source code, not sure exactly how he's "wrecking jQuery". 2) Semicolons are still in debate amongst the JS community, I don't think there's a consensus on whether they're needed or not and it seems to boil down to personal preferences. 3) This reeks of ad hominem, how exactly is Paul Irish "hipster"?…

> 2) Semicolons are still in debate amongst the JS community, I don't think there's a consensus on whether they're needed or not and it seems to boil down to personal preferences. They are needed. This var func = function(x) { console.log(x); }; func; (42); is different from this var func = function(x) { console.log(x); } func (42)

You're right that your (very contrived) examples are different. But if anybody on my team writes code like this, it doesn't pass code review.

Re: Bling – the $ of jQuery without the jQuery

#35
post #32

Note that work is being done to give `NodeList`s the `Symbol.iterator` property so in new browsers it's trivial to use the native DOM with `for(let x of nodeList)` loops making our lives easier. This will make our lives easier :)

But I must say that I don't really like the list comprehensions syntax in JS.It leaves a lot to be desired.

Re: Bling – the $ of jQuery without the jQuery

#36
post #23

Earlier quoted context omitted.

> 2) Semicolons are still in debate amongst the JS community, I don't think there's a consensus on whether they're needed or not and it seems to boil down to personal preferences. They are needed. This var func = function(x) { console.log(x); }; func; (42); is different from this var func = function(x) { console.log(x); } func (42)

They aren't needed at all. Semicolons in JS are optional. Knowledge about how ASI works, on the other hand, is mandatory.

They aren't needed at all. Semicolons in JS are optional.

Which becomes really annoying if you just want to quickly concatenate a few files together.

Sure, it's something that you can fix yourself; I'd consider it a common courtesy to include at least one, though.

Re: Bling – the $ of jQuery without the jQuery

#37
post #2

This does three things: 1. Alias document.querySelectorAll to $. 2. Alias node.on to node.addEventListener. 3. Make NodeList a sub-type of Array (so you can use forEach etc on node lists as you would on arrays). The $ of jQuery also does a few other things, e.g. create HTML elements from text ($(' ') creates a div element with CSS class "foo") and wrap elements in a node list ($(document.body) creates a node list con…

wrap elements in a node list

This is not correct. You may say that it wraps or outputs elements in a node list like object but it is not the real deal. If you examine the emitted jQuery objects using instanceof or any other method, you'd see that they are not related to NodeList in any way. They're just generic objects of Object type.

Re: Bling – the $ of jQuery without the jQuery

#38
post #28
post #18

Can someone explain the new trend to not use jQuery?

A lot of developers originally used jQuery as a cross-browser compatibility library when that was still a major concern. Along the way, jQuery has added tons of extra helper functions and wrappers (ie, .ajax(), .post(), event binding helpers, etc). This has been amazing for web development, but it's also been such a major pillar of web development that a lot of front end developers don't actually know what's happenin…

I would add that a lot of the time, your browser-set is very small. For mobile apps, many of which use web views for at least some functionality, you're writing to one or two versions of WebKit only.

Re: Bling – the $ of jQuery without the jQuery

#39
post #18

Can someone explain the new trend to not use jQuery?

New trend? It was a new trend in 2011. Jquery isn't needed anymore with HTML5 browsers, all the useful API have been added with native speed advantage. If you still have to support IE8 than Jquery is great.
Post reply on HN