jQuery.fn.load() is deprecated solution

How to get rid of jQuery.fn.load() deprecated notices in Wordpress manually if you can not update.

4736 views
d

By. Jacob

Edited: 2021-02-26 14:49

Wordpress development is not always easy; if you rely on third party plugins and themes, then chances are that you will have encountered the jQuery.fn.load() is deprecated error. When investigating the message it may appear like this in the control panel:

https://example.beta/wp-content/themes/Travelo/js/theme-scripts.js: jQuery.fn.load() is deprecated

The problem happens because the load() method is deprecated, but still being used by a plugin or theme. In my case, this was the Travelo theme that had to be updated — but sometimes updating a theme or plugin still does not solve the problem.

First and foremost, if you paid money for the plugin or theme that is causing the error, then I would urge the developers to fix the problem as fast as possible. It is what they are paid for after all.

If you still want to fix the problem yourself, and if you know what you are doing, you can actually easily fix this problem by replacing the load() method with on('load', ...); a deprecated implementation might look like this:

tjq(this).load(function() {
  tjq(this).closest(".middle-block").middleblock();
});

We may change this like so:

tjq(this).on('load', function() {
  tjq(this).closest(".middle-block").middleblock();
});

The problem also occurs for other methods. You can use the following:

It seems you can do a drop-in replacement of live() with on(). For example:

$('.travelo-install-demo-button1').live('click', function(e) { 
  // ...
});

Would become:

$('.travelo-install-demo-button1').on('click', function(e) { 
  // ...
});

Tell us what you think:

  1. How to insert code right after body opening tag, and creating a wrapper around the code in a page using PHP output buffering and the Wordpress shutdown hook.
  2. How to properly remove the title from a Wordpress post, and how to do it for specific post types.
  3. There is no function to select a post by slug name (post name), but we can create our own function to do it; find out how in this tutorial.
  4. How to properly customize Wordpress based website, where to add your own code, and how to override existing functionality.
  5. How to manually move a Wordpress website to another domain name, and copy the database and the files from the old site.

More in: WordPress Tutorials