dvancouver
dvancouver

Reputation: 723

JQuery .get vs load() performance question

Is it better to use

$.get("http://www.example.com/mydirectory", function(data) {
        $(".someclass").html(data);
});

or

$('.tripPlannerBottom').load("http://www.example.com/mydirectory");

any speed or performance benefits?

Upvotes: 8

Views: 6148

Answers (2)

redsquare
redsquare

Reputation: 78667

.load, .get & .post are wrappers around the .ajax method. There is no performance boost apart from few chars you save in typing without having to create the settings if using the .ajax method.

Upvotes: 9

Cody Caughlan
Cody Caughlan

Reputation: 32748

I have no benchmark data to back my claim up, but by looking at the source, $.get + html() and .load() are basically the same. .load() is a convenience wrapper around .get() + html()

Upvotes: 12

Related Questions