Tutorials

jQuery Migrate: What It Is, Why It Exists, and When to Remove It

Understand jQuery Migrate, how it works, when to use it, and how to safely remove it during upgrades. Includes real examples and fixes.

jQuery Migrate: What It Is, Why It Exists, and When to Remove It

jQuery Migrate is a compatibility plugin for upgrading applications that still rely on jQuery APIs or behaviours changed in newer jQuery releases.

It can restore selected legacy behaviour and report migration warnings, giving a team time to update old code before removing the compatibility layer.

Use the Migrate Version for Your Upgrade Path

jQuery Migrate has major versions that correspond to different jQuery migration paths. Do not choose a Migrate release from an old blog post and assume it matches the jQuery version you are adopting.

Check the official jQuery Migrate project and its upgrade documentation for the supported combinations.

Load Migrate after jQuery:

<script src="jquery.min.js"></script>
<script src="jquery-migrate.js"></script>

During development, use the build that reports migration warnings so the console can identify deprecated or changed behaviour.

Treat Warnings as Migration Work

A warning such as:

JQMIGRATE: jQuery.fn.click() event shorthand is deprecated

points to code that should be reviewed.

For example, old event shorthand:

$('.btn').click(function () {
  submitForm();
});

can be replaced with:

$('.btn').on('click', function () {
  submitForm();
});

Likewise, code using older event APIs such as .bind() can usually move to .on().

The exact replacement depends on the warning and the target jQuery release, so use the current jQuery API documentation and Migrate warning documentation rather than applying replacements mechanically.

Use Migrate During the Upgrade

Adding Migrate and leaving every warning unresolved defeats much of its purpose.

A migration usually looks like:

upgrade jQuery

add matching Migrate version

exercise application code

collect warnings

fix deprecated behaviour

repeat tests

remove Migrate when compatibility support is no longer required

A project may temporarily ship Migrate in production during a staged upgrade, but that should be an explicit compatibility decision rather than an accidental permanent dependency.

Exercise the Code Paths That Matter

Many migration warnings appear only when the relevant code executes.

Test:

forms
menus
dialogs
AJAX flows
validation
navigation
third-party widgets
rare administrative screens

Warnings from interaction-driven code appear only after those paths run.

For a larger application, browser automation can repeatedly exercise important flows. A tool such as Playwright can help cover the same paths after each round of migration fixes.

Third-Party Plugins Can Block Removal

Migration warnings do not necessarily come from application code.

An old jQuery plugin may call deprecated APIs internally. In that case the choices may be to upgrade the plugin, patch or replace it, remove it, or keep the required compatibility layer until the dependency can be changed.

This is one reason to inspect warning stack traces rather than simply counting console messages.

Verify Behaviour After Each Fix

A migration warning identifies compatibility work; it does not prove that a particular replacement preserves application behaviour.

After changing an event handler, selector, AJAX call, or DOM manipulation path, run the relevant tests and exercise the feature.

Useful coverage can include:

  • unit tests for affected helpers
  • browser tests for user flows
  • visual checks for UI behaviour
  • network assertions for AJAX requests
  • console monitoring for new Migrate warnings

The final removal test is straightforward: run the application without Migrate and execute the same coverage again.

Keep Compatibility Fixes Focused

A jQuery upgrade can expose old code that is tempting to modernize all at once.

Keep compatibility fixes small enough to review. Replacing a deprecated API and rewriting the surrounding component in the same change makes it harder to tell whether a regression came from the migration or the redesign.

Larger refactors can follow after the compatibility baseline is stable.

When jQuery Migrate Is Useful

It is most useful when:

an existing application is moving between jQuery generations
the codebase contains deprecated APIs
third-party plugins complicate the upgrade
the team needs warnings to locate compatibility work
the migration must happen incrementally

A new application using the target jQuery version and current APIs has no migration problem for the plugin to solve.

jQuery Migrate is therefore best treated as upgrade tooling: introduce it for a defined migration path, use its warnings to find legacy behaviour, test each correction, and remove the compatibility layer when the application and its dependencies no longer need it.

Top