jQuery: get() is slower compared to load()

Viewed 1515

Obvious question - why?

I need to get from external page table cell, and then inject it to the current page. Complex selectors are used.

This is with .load():

$('#check').load('https://bla-bla-bla .small:contains(Something)+.small:lt(1)');

This is with .get():

function showGetResult()
{
     var result = null;
     var scriptUrl = "https://bla-bla-bla";
     $.get(scriptUrl, function(data) {
            result = $(".small:contains(Something)", data).next().html() || "Error";
            $('#check').append(result);
     });
}

load() get data faster by average 1-2 seconds. But I like get() - since I can have string result, not an object.

Can someone explain why load() works faster?

1 Answers
Related