Live data from Hacker News

Bling – the $ of jQuery without the jQuery

gist.github.com

131–138 of 138 posts

Re: Bling – the $ of jQuery without the jQuery

#131

If you quite literally want "what jQuery uses to select things" and nothing else, you're really looking for Sizzle. http://sizzlejs.com/

These days it's not Sizzle, which is mostly support for non-qSA browsers and support for custom pseudo-selectors. jQuery's modern element selection is https://github.com/jquery/jquery/blob/master/src/selector-na...

Nice, thanks for the update.

Re: Bling – the $ of jQuery without the jQuery

#132
post #29

Earlier quoted context omitted.

You are arguing against a strawman - no one is claiming otherwise. All paul_irish wanted to show is that people often use jQuery without realizing that most of what they do is also possible with the current browser APIs. jQuery does a ton more (animation, ajax etc) - the point was not to "rewrite jQuery in 10 lines" (that's Zepto)

The subtitle of the article is "Because you want the $ of jQuery without the jQuery". With such an ambiguous statement, I think we can afford ceronman the benefit of the doubt. Furthermore, I don't think he's making up a strawman at all now matter how you look at it. He agreed with the article. You CAN re-implement jQuery in 10 lines of code if all you want is 0.1% the functionality of jQuery. That's what the article…

> The subtitle of the article is "Because you want the $ of jQuery without the jQuery". With such an ambiguous statement, I think we can afford ceronman the benefit of the doubt.

Headlines are supposed to be ambiguous, in the sense that they are much shorter than the content they accompany (and thus there are fewer possible headlines than there are possible articles). You're expected to read the content.

Re: Bling – the $ of jQuery without the jQuery

#133
post #81

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"?…

How is he hipster? Oh, he is. This very snippet shows how regrettably hipster the web development scene has become. It's all trend-driven. And particularly Paul, as popular as he is, should be real carefuly about his opinions, because he's a trend-setter. The moment he says jQuery is useful (like here https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0Rlh... ) many developers will think likewise. The moment he…

You're not backing your comments with anything. "Oh this is hipster because I say so", hehe, alright dude

Re: Bling – the $ of jQuery without the jQuery

#134

Yes, you can re-implement jQuery in 10 lines of code... if you only support 0.1% of the functionality of jQuery. jQuery was a game changer for web client side development. Thousands of work hours have been spent on it. It had a specially important role of dealing with all the inconsistencies between browsers. If you don't use all the features, nowadays you can just create a custom build with the stuff you want. If yo…

I wrote this thing because I wanted the classic jQuery API goodness for 1) grabbing elements and 2) binding events. Yes, obviously this gist doesn't cover the feature set of jQuery; and in my brief readme, I hope I didn't convey something different. We will always need jQuery. We need a well maintained library that addresses browser inconsistencies and provides a better API. (Don't expect my gist to be maintained lik…

Why did you choose those two functions? There are already small NPM modules like dom-events for attaching and triggering events, and qwery, or sizzle for querying selectors.

Re: Bling – the $ of jQuery without the jQuery

#135

If you are using $ signs all over your code, they'd better refer to jquery and nothing else. jQuery has, for better or worse, become such an integral part of web development, the $ namespace is pretty much owned by it at this point. If you do want to use it for not-jquery, it should be something that is drastically different so someone new trying to patch a bug on prod doesn't run around in circles wondering why thei…

If you're still relying on the global namespace you should stop. When I require('jquery') I'll name it what ever I damn well please, and you better get used to that because ES6 modules are here.

Re: Bling – the $ of jQuery without the jQuery

#137
post #88
post #85

Earlier quoted context omitted.

With bling.js: .text: $('.selector')[0].textContent .css $('.selector')[0].style .html: $('.selector')[0].innerHTML .val: $('.selector')[0].value .first: $('.selector')[0] .closest: n/a

jQuery's $.text/html() set the text of all matched nodes, not just the first one. I can use key-value object to assign multiple css property, and it can set the style on all matched nodes. If there are no matched elements, Bling's $()[0].xxx = value" will raise exception.

That's the thing, Bling.js also makes it easy to set the text/css on all nodes:

    $('.foo').forEach(el => el.textContent = 'bar')
    $('.foo').forEach(el => el.style.top = '0px')

Re: Bling – the $ of jQuery without the jQuery

#138
post #40

Well, the thing with jQuery is that if you use a CDN to get it from, then it is a very high chance that the client already has the library cached, so the bandwidth problem is actually not that much of a problem now.

It's probably better for most sites to minimize the number of DOM lookups by combining jQuery with the rest of your vendor code in a vendors.js (or similar) file. The chance for a cache hit is very low (and getting lower with the trend away from jQuery).

That said, test the 2 approaches and see which works better for your site.

Post reply on HN