jQuery.fn.load() is deprecated solution

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

1366 views

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. Should you use Wordfence or Malcare? And are they even sufficient security tools? Securing a Wordpress site with third party plugins and themes is probably harder than you think.
  2. There can be several different reasons why jQuery might be undefined; maybe it is not yet loaded, or maybe a script is unloading it. In this tutorial I will explain some of the problems and solutions that I have come by when developing Wordpress websites.
  3. How to correctly determine file system paths when developing for Wordpress and avoiding inconsistencies.
  4. How to secure your Wordpress website by disabling write access to certain files and directories.
  5. Using HTML forms with the Divi Wordpress theme is not easy, luckily we can just include our own custom HTML, and it will even show in the editor!

More in: WordPress Tutorials