Live data from Hacker News

Bling – the $ of jQuery without the jQuery

gist.github.com

81–90 of 138 posts

Re: Bling – the $ of jQuery without the jQuery

#81
post #6

Tries to play it cool by wrecking jQuery? Check. No semicolons? Check. Put together by Paul Irish? Check. Yep, this submission is Hipster 1.0 Certified.

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 spits this utter crap despising jQuery, many developers will, again, adopt the same opinion without hesitation.

Re: Bling – the $ of jQuery without the jQuery

#83
post #46

Earlier quoted context omitted.

>> Tries to play it cool by wrecking jQuery? > not sure exactly how he's "wrecking jQuery" The grandparent is misguided, but I believe they mean using '$' as the QSA. The grandparent probably uses script tags and globals in which case there would be a conflict if a script tag library requires window.$. JS modules should var $ = require('jquery') (or equivalent) and then use the $ in their local scope if they need jqu…

What modules? You mean CommonJS or was it AMD or ECMAScript 6? Still a straw man IMHO :-)

CommonJS, since npm (which is mainly commonjs) is a few hundred/thousand times larger than the whatever else.

Re: Bling – the $ of jQuery without the jQuery

#84
post #28

Earlier quoted context omitted.

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…

> jQuery as a library has now become huge > So if you can cut down your cold cache loading times by not > including the full jQuery library, that's probably a win jQuery 1.11.3 is 38.4 KB when minified and gzipped. jQuery 2.1.4 is 34.1 KB when minified and gzipped. I'm all for eliminating unnecessary bloat, but it's not as if a jQuery download is a huge amount of data to fetch. While jQuery is not a framework, most f…

For comparison, the site I work on serves up thousands of content images. I just did a quick scan across our media directory with a bash script, and the average image size was 78.0 KB

Re: Bling – the $ of jQuery without the jQuery

#85
post #80

Nice. So where is my $.text(), $.css(), $.html(), $.val(), $.first(), $closest(), etc.?

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

Re: Bling – the $ of jQuery without the jQuery

#86
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…

jQuery was and still remains useful... Were you missing a "/s" from the end of your statement?

Re: Bling – the $ of jQuery without the jQuery

#87
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.

So they're not really optional. What they are is necessary and if omitted the engine attempts to put them in automatically. The rules for automatic semicolon insertion are in section 7.9 of the ECMAScript 5 standard (http://www.ecma-international.org/publications/files/ECMA-ST...).

This means you're omitting something that is required by the engine but not necessarily required in the syntax which boils down to you losing control of where semicolons end up possibly making your code do something you did not intend because you either misunderstood the rules of automatic semicolon insertion or there was a bug in the syntax parser being used.

Re: Bling – the $ of jQuery without the jQuery

#88
post #85
post #80

Nice. So where is my $.text(), $.css(), $.html(), $.val(), $.first(), $closest(), etc.?

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.

Re: Bling – the $ of jQuery without the jQuery

#89

“jQuery is not need anymore with modern browsers.” Bull. Shit. This document proves why, and is written by the same guy that is now pushing this “you don’t want jQuery!” stuff. https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0Rlh...

>> “jQuery is not need anymore with modern browsers.”

> Bull. Shit.

Depends on the target environment(s). If you only want to support evergreen browsers then there is no reason you need jQuery; you're going to have the native DOM APIs and you don't care about compatability.

jQuery's big win is two fold, in my opinion. One it has awesome, chain-able syntax and two (most important) it has awesome backwards compatibility with terrible browsers. If you don't need two then is one worth bringing in another dependency? Maybe or maybe not.

Re: Bling – the $ of jQuery without the jQuery

#90
post #76

Earlier quoted context omitted.

Sorry for confusion, what i meant was: yes DOM API is a bit verbose, but jQuery is exactly the opposite in a bad sense: it's using too few words to express too many different things.

jQuery uses CSS selectors, which is fairly clear if you have a general understanding of them.

So does querySelectorAll, that's not the issue with jQuery API.

The problem is that "jQuery" function, aliased as "$" has 9 signatures (doing 9 different things, depending on which arguments you send to it), while querySelectorAll does only one thing

Post reply on HN