Fix jQuery and WordPress “url.indexOf is not a function” error

So, you have updated your WordPress to 5.6 and something strange happened to your website? You open the inspector (Command+Option+C (Mac) or Control+Shift+C (Windows, Linux, Chrome OS), and you find a red message like url.indexOf is not a function error ? Wtf Javascript? How to fix it?

WordPress 5.6 comes with an updated jQuery version: 3.5.1.

WordPress 5.5 stopped enabling the jQuery Migrate helper script by default, and with the upcoming release of WordPress 5.6, the bundled version of jQuery will be upgraded (from 1.12.4-wp to 3.5.1).

What this involves for users, is that any plugin or theme that previously relied on the jQuery Migrate tool to work as expected (due to being older code, or just a missed update to deprecated functions), may now have unexpected behaviors.

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

jQuery blog

So the correct way is to change in your javascript all your occurrences of

$(window).load(function() { ... });

into something like

$(window).on('load', function() { ... });

But sometimes errors are not related to your own code, right? So what to do?
Try adding this code before other javascript scripts and after jQuery inclusion.

jQuery.fn.load = function(callback){ jQuery(window).on("load", callback) };