Home > jquery > jQuery Anti-Patterns for Performance

jQuery Anti-Patterns for Performance

September 11th, 2009
  1. #1

    Nice presentation dude. Great slides.

    Wish I coulda been there to see it in person!

  2. Pablo
    #2

    Big Loada!

  3. bganicky
    #3

    Thanks for nice slides. Nice tip/trick on slide 36…in need of this right now. :)

  4. seutje
    #4

    too bad I couldn't be there :'(

  5. #5

    @Pablo, Hah! thank you for getting the reference. :) Craig David and Squarepusher ref's on a talk about selectors is just.. a must do!

  6. #6

    So in general my recommendation was to not use the context argument for any perf advantage, I only see it useful as a shorter way of writing $(this).find(…

    But Yehuda Katz mentioned that it has a decent use in live() in jquery 1.3.3:

    $("td", "table").live(…
    will scope the delegation to existing tables

    I have yet to do some performance testing on this. But this may be worth considering.

  7. dizzley
    #7

    Paul, thanks for a fascinating presentation. I wish I could have heard you too. I'm just getting into jquery so it was illuminating. It brought back some of my best programmer's instinct. :)

    …and I've picked up your RSS feed!

  8. #8

    Great presentation Paul! My fav slide is #54 — All that expression'y goodness! :D

  9. Prestaul
    #9

    @Paul:

    $('td', 'table').live(...

    will not be scoped to tables, because the context of the resulting jQuery object is still the document. To change the context you have to pass an actual DOM node.

    $('td', 'table').context; // => document
    $('td', $('#mytable')[0]).context; // => table node

    I think we're going to be seeing a lot of code like this when v1.4 hits the shelves:

    var table = $('#mytable')[0];
    $('td', table).live(...
  10. #10

    Prestaul, you are 100% correct.
    This definitely lends to some odd looking code, but yah right now that's the best way…

  11. Aleksandr Motsjonov
    #11

    Very-very nice and usefull. I take couple of your recepies. Thank you.

  12. Kailden
    #12

    This is a great presentation. Thanks!

  13. #13

    Looks like the slides are down :(

  1. | #1
  2. | #2
  3. | #3
  4. | #4
  5. | #5
  6. | #6
  7. | #7
  8. | #8

For code blocks, use <pre lang="javascript" escaped="true">. css and html4strict are also accepted.

i left this space here for you to play. <3