Live data from Hacker News

Bling – the $ of jQuery without the jQuery

gist.github.com

101–110 of 138 posts

Re: Bling – the $ of jQuery without the jQuery

#101

Earlier quoted context omitted.

>> “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 compatibilit…

> If you only want to support evergreen browsers then there is no reason you need jQuery False. Read the first sentence of the document I linked to. “…developers should be aware that ditching libraries, like jQuery, can easily require large amounts of research on their end to avoid bugs ( even in modern browsers ).” Bear in mind it’s Paul Irish who wrote that.

> False

> Read the first sentence of the document I linked to.

Oh I did. Look through many of the bugs they outline; many are incredibly minor and inconsequential unless you're doing things related (or semi related) to supporting older browsers.

> Bear in mind it’s Paul Irish who wrote that.

Yup; I don't see his posts being quite in conflict like many here seem to think. Plus his opinion has probably evolved overtime anyway (he wrote that document a year and a half ago).

Re: Bling – the $ of jQuery without the jQuery

#102

Earlier quoted context omitted.

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.

In the worst case, you can do something along the lines of

    [file1, file2, file3].join(';\n')
albeit if you're using any kind of post-processing tool, like UglifyJS or Google's Closure compiler, then everything just works, as these tools actually parse JavaScript. There's usually no need to explicitly concatenate the code prior to minification or other processing.

Re: Bling – the $ of jQuery without the jQuery

#103
post #62

Earlier quoted context omitted.

Alternatively: console.log("woof") void function() { console.log("foo") }() There really is only one ASI rule you need to remember [0] in practice: don't begin a new line with ( or [ if it's intended to be a new statement. On this topic, it could so easily have been different; I found this interesting from Brendan Eich [1]: > I wish I had made newlines more significant in JS back in those ten days in May, 1995. Then…

> There really is only one ASI rule you need to remember [0] in practice: don't begin a new line with ( or [ if it's intended to be a new statement. Here's an even easier and clearer one: finish every statement with a semicolon.

Mindlessly inserting unnecessary syntax instead of learning the damn language. Hacker News should be proud of its lusers.

Re: Bling – the $ of jQuery without the jQuery

#104

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…

It's not even a project, it's a GitHub Gist. Talk about a lot of fuss being made over nothing.

Re: Bling – the $ of jQuery without the jQuery

#105

Earlier quoted context omitted.

> 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 no…

You're only "losing control" if you don't know how ASI works, which is well-defined in the ECMAScript standard. Bad programmers that can't understand ASI will be also confused by the floating point semantics, promises and other basic concepts — there are many ways of "making your code do something you did not intend" in JS, but that's no excuse for bashing language features. Fact check: ASI is a fully legitimate part…

> Bad programmers that can't understand ASI will be also confused by the floating point semantics, promises and other basic concepts — there are many ways of "making your code do something you did not intend" in JS, but that's no excuse for bashing language features.

This is a terrible attitude. There is no reason you may not understand every case in which a semi colon is automatically inserted but can still understand floating point, promises and other things. Automatic semicolon insertion isn't really a "basic concept"; it's a convenience for those who elide them and nothing more (the ECMAScript 5 standard even states this).

> Fact check: ASI is a fully legitimate part of the language (as in, it's in standard, it's documented, and supported across the board), so demonizing it is every bit as silly as e.g. deprecating C macros.

I'm not "demonizing" it but if you look at the standard the engine still requires semicolons it just fills them in for you if you miss them. This is vastly different than your deprecation of C macros example. Yes it's documented but it's non-obvious unless you've literally looked it up to learn it. I'm also not sure why you insisted on letting me know it's a "fully legitimate part of the language (as in, it's in standard, it's documented, and supported across the board" when I linked to the standard and stated exactly where to look for its definition...

> Learning the language helps with the the issues you outlined, while magical thinking (uguuu, semicolons good, no semicolons bad, uguuu) for the most part doesn't.

Sigh. Automatic semicolon insertion is only documented. There are no errors or warnings or other information. Many developers, who understand more advanced topics, may not even know about it. The language does nothing to help with this. It's far better to be more explicit than assuming everyone who looks at your code understands the full ECMAScript 5 standard.

Re: Bling – the $ of jQuery without the jQuery

#106

Earlier quoted context omitted.

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

> 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 front-end JS frameworks are the same size or bigger and don't receive as much attention for being bloated. Remember size isn't as much of an issue when it's less than 100kb (though 3G or less networks that will still be painful). The biggest issue is yet another fi…

> The biggest issue is yet another file for the browser to fetch.

There's no reason you can't concatenate jQuery with the rest of your JS.

Re: Bling – the $ of jQuery without the jQuery

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

This explains it pretty well. I always have to argue with other developers to not break IE8. The comeback is always that it represents less than 1% of our sales, I argue that the 1% of sales is still more than their salaries.

As much as I'd love to stop keeping track of IE8 bugs, for a lot of sites this isn't possible. And, IMHO, this cavalier attitude is what causes many websites now to work "best" (read: only) in Chrome. It's true that a lot of sites (I'm thinking Webapps) don't need jQuery at all, and a lot of sites can get away with just using Sizzle, but 28kB is a small price to pay for the utility functions, cleaner AJAX API, event binding registry, etc. If you don't need them, by all means don't use it.

Re: Bling – the $ of jQuery without the jQuery

#108

Earlier quoted context omitted.

`$` is the point of entry to almost everything jquery provides, so he's not implementing jquery's `$` since the gist does not come even remotely close to jquery's featureset. He's implementing a completely different function with the same name. If behaviour is considered irrelevant, here's my one-line implementation of $: var $;

But the post isn't claiming to provide everything that Jquery provides just replacing the "$" function. The "$" does two things in jQuery. 1. Its the DOM selection function. This is what he's replacing. This is the real "functionality" of the $ function. The main bit missing is that it won't create a new element if you pass in a string. Return a collection of matched elements either found in the DOM based on passed a…

3. It also provides a DOMContentLoaded handler.

$(function(){console.log('DOMContentLoaded')})

Re: Bling – the $ of jQuery without the jQuery

#109

Earlier quoted context omitted.

> There really is only one ASI rule you need to remember [0] in practice: don't begin a new line with ( or [ if it's intended to be a new statement. Here's an even easier and clearer one: finish every statement with a semicolon.

Mindlessly inserting unnecessary syntax instead of learning the damn language. Hacker News should be proud of its lusers.

I don't have a photographic memory. If "learning the language" means rote memorization of an inconsistent set of rules for how the fucking code is parsed, then you're goddamn right I'd rather mindlessly insert a character that obviates that.

Re: Bling – the $ of jQuery without the jQuery

#110

Earlier quoted context omitted.

You're only "losing control" if you don't know how ASI works, which is well-defined in the ECMAScript standard. Bad programmers that can't understand ASI will be also confused by the floating point semantics, promises and other basic concepts — there are many ways of "making your code do something you did not intend" in JS, but that's no excuse for bashing language features. Fact check: ASI is a fully legitimate part…

> Bad programmers that can't understand ASI will be also confused by the floating point semantics, promises and other basic concepts — there are many ways of "making your code do something you did not intend" in JS, but that's no excuse for bashing language features. This is a terrible attitude. There is no reason you may not understand every case in which a semi colon is automatically inserted but can still understa…

It's the same reason that, yes, you can put "var x" in an if-block, but it's bad practice because it misleads the reader (even one who knows that Javascript is function scoped) into thinking that x is block-scoped.
Post reply on HN