Skip to content

Fix JS jQuery Migrate Warnings#1024

Open
faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad:fix/issue-988-jquery-migrate-warnings
Open

Fix JS jQuery Migrate Warnings#1024
faisalahammad wants to merge 1 commit intowp-media:developfrom
faisalahammad:fix/issue-988-jquery-migrate-warnings

Conversation

@faisalahammad
Copy link
Copy Markdown

@faisalahammad faisalahammad commented Feb 27, 2026

Summary

Fixes deprecated jQuery methods (.change(), $.isArray(), and $.trim()) that trigger JQMIGRATE warnings in the console.

Fixes #988

Problem

Several JavaScript files in the plugin use old jQuery methods that have been deprecated in newer jQuery versions, causing "JQMIGRATE" warnings in the browser's developer tools console.

Solution

Replaced deprecated jQuery methods with native vanilla JavaScript equivalents (Array.isArray(), String.prototype.trim()) and updated event binding to use .on('change', ...).

Changes

assets/js/pricing-modal.js

Before:

	$('#imagify-toggle-plan').change(function() {
		var isChecked = $(this).is(':checked');

After:

	$('#imagify-toggle-plan').on('change', function() {
		var isChecked = $(this).is(':checked');

Why this works:
The .change() shorthand is deprecated. Using .on('change', ...) is the standard, future-proof way to bind events in jQuery.

_dev/src/bulk.js

Before:

if ( ! response.data || ! ( $.isPlainObject( response.data ) || $.isArray( response.data ) ) ) {

After:

if ( ! response.data || ! ( $.isPlainObject( response.data ) || Array.isArray( response.data ) ) ) {

Why this works:
$.isArray() is deprecated in favor of the native Array.isArray(), which is faster and natively supported in all modern browsers.

assets/js/media-modal.js & assets/js/options.js

Before:

context = $.trim( contextId ).match( /^(.+)_(\d+)$/ );

After:

context = String( contextId ).trim().match( /^(.+)_(\d+)$/ );

Why this works:
$.trim() is deprecated. The native String.prototype.trim() achieves the same result without relying on jQuery.

Testing

Manual Testing

Test Case 1: Verification of JQMIGRATE warnings

  • Steps:
    1. Open the Imagify Settings page.
    2. Navigate to Media Library and open an image's media modal.
    3. Navigate to Bulk Optimization page.
    4. Open the Imagify pricing modal and toggle the plan (monthly/yearly).
  • Result: No JQMIGRATE warnings related to .change(), $.isArray(), or $.trim() are thrown in the browser console.

Build Artifact

For manual verification, use the generated build locally attached in the folder imagify-fix-issue-988-jquery-migrate.zip.

imagify-fix-issue-988-jquery-migrate.zip

Installation: WordPress Admin > Plugins > Add New > Upload Plugin

Screen recording

https://videos.faisalahammad.com/recordings/ZcOJ74yWReTvjVVeuRYH

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses jQuery Migrate console warnings in the Imagify plugin by replacing deprecated jQuery APIs with modern equivalents across several frontend/admin scripts.

Changes:

  • Replace deprecated jQuery event shorthand .change() with .on('change', ...) in the pricing modal scripts.
  • Replace deprecated $.isArray() and $.trim() usages with native Array.isArray() and String(...).trim() in bulk/options/media-modal logic.
  • Regenerate/update built/minified assets to reflect the source changes.

Reviewed changes

Copilot reviewed 6 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
assets/js/pricing-modal.js Updates plan toggle handler to use .on('change') instead of deprecated .change().
assets/js/pricing-modal.min.js Built/minified output reflecting the pricing modal event binding change.
_dev/src/bulk.js Replaces $.isArray() with Array.isArray() in bulk processing logic.
assets/admin/js/bulk.js Built admin bundle reflecting the bulk script change(s).
assets/js/options.js Replaces $.trim() with String(...).trim() for API key validation.
assets/js/options.min.js Built/minified output reflecting the options trim change.
assets/js/media-modal.js Replaces $.trim() with String(...).trim() when parsing contextId.
assets/js/media-modal.min.js Built/minified output reflecting the media modal trim change.
assets/js/library.min.js Minified asset changed as part of rebuild (unrelated to the deprecated API replacements described).
assets/js/jquery.twentytwenty.min.js Minified asset changed as part of rebuild (unrelated to the deprecated API replacements described).
assets/js/jquery.event.move.min.js Minified asset changed as part of rebuild (unrelated to the deprecated API replacements described).
assets/js/files-list.min.js Minified asset changed as part of rebuild; still contains a deprecated $.trim() usage (see comment).
assets/js/beat.min.js Minified asset changed as part of rebuild (unrelated to the deprecated API replacements described).
assets/js/admin.min.js Minified asset changed as part of rebuild (unrelated to the deprecated API replacements described).
assets/admin/js/runtime.js Runtime bundle updated as part of rebuild.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@remyperona remyperona added this to the 2.2.8 milestone Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecated notices while script_debug set to true

3 participants