Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Consider caching your element selectors like this:

var $image = $('#my-div img');

This way jQuery doesn't have to traverse the DOM more than once to select the element.

Also, I believe you can do all of your mousedown() event code in one block.

Edit: oops, upon further inspection, I see you are doing this all in the console. Caching the selector is still possible, but now I understand why you did the mousedown() event the way you did.



Hi sparkygoblue, author here, thanks for the feedback! As you mentioned in your edit, I tried to break every step into simple-to-follow pieces.

Def let me know if you have any other suggestions :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: