News for hackers. Stuff that matters.
Re:Making a Go program 70% faster by avoiding common mistakes by emehrkay on Thursday March 17, 2016 @09:59AM (#11304342)
It's like seeing this in everyone's JavaScript

    $('.some_selector').action();
    ...
    $('.some_selector').anotherAction();
Re:Making a Go program 70% faster by avoiding common mistakes by Cthulhu_ on Thursday March 17, 2016 @11:32AM (#11304957)
Isn't there a decent caching system behind that?

OTOH, .action() could change the whole dom so that .some_selector matches something else or nothing at all, so I guess jquery couldn't make that assumption / optimization without knowing what .action() does, or without doing a deep analysis of what DOM elements .action() altered and whether the selector on the next line is affected.

Re:Making a Go program 70% faster by avoiding common mistakes by TheHegemon on Thursday March 17, 2016 @06:07PM (#11308017)
Thank you! That is one of my greatest pet peeves.

Or needless selectors like $('div.some-div input.some-input') where the classes are never used on anything other than divs/inputs. Another thing I've seen: $('#someId #childId').

Re:Making a Go program 70% faster by avoiding common mistakes by maxxxxx on Thursday March 17, 2016 @11:33AM (#11304973)
I have been in discussion where somebody would argue that using a variable for $('.some_selector') would be inefficient because it's more lines of code.
Re:Making a Go program 70% faster by avoiding common mistakes by Cshelton on Thursday March 17, 2016 @11:02AM (#11304764)
I excluded some candidates right off the bat for this...grabbing the same element 4 times in one function....no I am not hiring you...