Re:JQuery 1.8b1: what’s new?
by MatthewPhillips on Friday June 22, 2012 @04:51PM
(#4148743)
I can't imagine why you'd need jQuery on mobile in the first place? What exactly are these core features that the standard DOM apis don't give you?
[ Parent
| on HN ]
Re:JQuery 1.8b1: what’s new?
by agildehaus on Friday June 22, 2012 @05:01PM
(#4148780)
I suppose you write all your code in assembly too? There's no room for going higher-level than the APIs exposed by the browser?
Re:JQuery 1.8b1: what’s new?
by MatthewPhillips on Friday June 22, 2012 @06:42PM
(#4149254)
I'm just curious what the higher-level APIs are that people need from jQuery that aren't available on mobile. I recall jQuery being popular for selector queries (available on all mobile browsers natively with querySelector and querySelectorAll) and for even listeners (offers no real advantage over addEventListener as far as I can tell).
Re:JQuery 1.8b1: what’s new?
by mark_story on Friday June 22, 2012 @09:28PM
(#4149753)
Well one nice affordance jQuery offers, is you can do manipulations en-mass without having to write out a loop, or use Array.forEach(). This helps simplify event binding and manipulation code. Also there are selectors in jQuery that are not available in querySelectorAll. And lastly querySelectorAll has some pretty buggy implementations. jQuery smoothes these out.
Binding event handlers in a loop is an anti-pattern greatly promoted by jQuery during several years. You should use event delegation.
Re:JQuery 1.8b1: what’s new?
by mark_story on Saturday June 23, 2012 @11:42AM
(#4151041)
Sure but $('.clicky').on('click', doSomething); means no loops at all, and will bind events to all matching elements. I don't think there is a native API way to do this.
Edit: typos
As far as I know jQuery is written with "native API", so there is obviously a way to do this in JavaScript.
document.body.addEventListener("click", function(e) {
if (e.target.className == "clicky") {
doSomething();
}
}, false);
Re:JQuery 1.8b1: what’s new?
by MatthewPhillips on Saturday June 23, 2012 @05:11PM
(#4151812)
document.getElementsByClassName('clicky').forEach(function(el) { el.addEventListener('click', doSomething); });
I'm not sure that works. getElementsByClassName (and Id and querySelector) returns a NodeList, not an Array, so there's no foreach, you have to convert it to an array first.
Re:JQuery 1.8b1: what’s new?
by MatthewPhillips on Sunday June 24, 2012 @09:02AM
(#4153230)
Array.prototype.slice.call(document.getElementsBy....
Re:JQuery 1.8b1: what’s new?
by mark_story on Wednesday June 27, 2012 @08:27PM
(#4169901)
That's also a ton of tying and a lot of code that a minifier can't reduce. I guess its possible, but do you really want to writing such verbose code?
Re:JQuery 1.8b1: what’s new?
by mkmcdonald on Friday June 22, 2012 @05:04PM
(#4148787)
The DOM API is clear enough that silly abstractions like "selector engines" are unnecessary.
The C vs. Assembly argument is such a silly non-point; apples and artichokes.
Selector engines are clearly not silly abstractions otherwise all major browsers would not have implemented querySelectorAll.
Re:JQuery 1.8b1: what’s new?
by MatthewPhillips on Friday June 22, 2012 @06:40PM
(#4149249)
But since they did, why use jQuery on mobile when 100% of mobile browsers support querySelectorAll?
Re:JQuery 1.8b1: what’s new?
by mkmcdonald on Friday June 22, 2012 @06:17PM
(#4149132)
…which is a façade for the existing CSS engine. Developers clamoured for it (right or wrong), and it was implemented.
Hilarious that you think that one of the core features of the most successful JS library in history is a "silly abstraction".
And JQuery is much more than just a selector engine.
"I can't imagine why you'd need jQuery on mobile in the first place?"
How about having the jQuery functionality on mobile device?, Recommended reading http://en.wikipedia.org/wiki/JQuery
Re:JQuery 1.8b1: what’s new?
by mkmcdonald on Friday June 22, 2012 @05:05PM
(#4148789)
A massive script such as jQuery does not belong on a mobile device, minified or not. Surely mobile developers would know that minimal script is best.
I browse to tons of pages on my phone every day that presumably use JQuery and work fine. We're not in the WAP days anymore.
Re:JQuery 1.8b1: what’s new?
by mkmcdonald on Friday June 22, 2012 @06:18PM
(#4149139)
I guess my humble iPod Touch that sputters out on bloated sites like GitHub just isn't up to snuff.
Try loading a page without script bloat and you'll see a noticeable difference.