jQuery 3.0 no longer supports .load

June 13, 2016 2:02 am Published by Leave your thoughts

I was contacted recently by a past customer whose site was no longer working after upgrading the jQuery to recently released jQuery 3.0.

Looking at the source code, I quickly realized that.load function was no longer firing in jQuery 3.0.

$( "#content" ).load(function() {
  // 
});

Thankfully, the work around is very straight forward.

All I had to do was replace .load with .on.

$( "#content" ).on( "load", function() {
  // 
});

I don’t really understand why .load was removed from jQuery. I know that jQuery 3.0 got rid of IE workaround (to slim down its code base) & heavy emphasis was placed on fast execution of code.

Perhaps this was the reason why .load was removed?

Tags: ,

Categorized in:

This post was written by hackya

Leave a Reply

Your email address will not be published. Required fields are marked *