Quick question about jQuery selector content efficiency

Posted by serg on Stack Overflow See other posts from Stack Overflow or by serg
Published on 2010-09-18T16:13:29Z Indexed on 2010/12/24 4:54 UTC
Read the original article Hit count: 192

Filed under:

I am loading HTML page through ajax and then doing a bunch of searches using selectors:

$.ajax({
    ...
    dataType: "html",
    success: function(html) {
        $("#id1", html);
        $(".class", html);
        //...
    }
}

Should I extract $(html) into a variable and use it as a content, or it doesn't matter (from performance point)?

success: function(html) {
        $html = $(html);
        $("#id1", $html);
        $(".class", $html);
        //...
    }

© Stack Overflow or respective owner

Related posts about jQuery