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

@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

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

1 participant