Make WordPress Core

Opened 11 months ago

Last modified 12 days ago

#64278 new task (blessed)

Remove remaining Internet Explorer code

Reported by: joedolson Owned by:
Priority: normal Milestone: 7.2
Component: General Version: 6.9
Severity: minor Keywords: has-patch
Cc: Focuses: javascript, css

Description

No version of Internet Explorer is still supported by WordPress, but miscellaneous scripts still contain hacks and workarounds to support it. This ticket is to track instances and resolve them.

Known examples:

  • Dashed border fix in imgareaselect ​Line 405
  • Rest selection area positions in imgareaselect ​Line 350
  • Fix background PNGs in farbtastic ​Line 38
  • Thickbox hacks ​Line 47, also line 301, 310
  • TinyMCE skins effecting galleries and gallery items
  • Early exit on autoresize textarea in dashboard.js ​Line 202
  • Early exit in customize/controls.js for IE9
  • tinymce/plugins/wordpress/plugin.js setting body classes
  • Check whether document.msHidden is present in heartbeat.js
  • emoji.js browser checks
  • twentytwentyone/assets/js/polyfills.js
  • gruntfile.js css minification compatibility
  • some settings in wp-admin/css/forms.css that are IE specific
  • use classlist methods in twentynineteen/js/touch-keyboard-navigation.js & priority-menu.js
  • timezone methods in dashboard.js

This is just a rough look at some of the possible issues. None of these are particularly important, but it would enable us to clean up the codebase in a variety of ways by removing exceptions.

Attachments (1)

64278.diff​ (26.0 KB ) - added by iflairwebtechnologies 11 months ago.
Remove Legacy Internet Explorer-Specific Code and Clean Up Outdated Scripts in WordPress

Download all attachments as: .zip

Change History (6)

#1 @szepe.viktor
11 months ago

This is a very good idea.

Last edited 11 months ago by szepe.viktor (previous) (diff)

@iflairwebtechnologies
11 months ago

Remove Legacy Internet Explorer-Specific Code and Clean Up Outdated Scripts in WordPress

#2 @iflairwebtechnologies
11 months ago

  • Keywords has-patch added
  • Version → trunk

This patch removes legacy Internet Explorer (IE) specific code and cleans up outdated scripts in WordPress, ensuring compatibility with modern browsers.

Changes Made:

  • Removed IE-specific hacks in JavaScript and CSS files (e.g., imgareaselect, farbtastic, thickbox, tinymce, heartbeat.js, emoji.js, dashboard.js).
  • Cleaned up IE-specific polyfills and workarounds in theme files (twenty-nineteen, twenty-twenty-one).
  • Refactored code in functions.php and polyfills.js to remove unnecessary IE support.

#3 @sabernhardt
8 months ago

  • Keywords has-patch removed

This can be an 'umbrella' or 'parent' ticket for tracking smaller tickets. The ​phase-out plan said that "individual tickets should be created to evaluate removing each instance of IE11 specific code."

Some admin scripts still might make sense to combine, but at least the front-end changes could have their own tickets.

  • Twenty Twenty-One is quite complex, so I created #64590 and its pull request to run the automated tests.
  • Twenty Nineteen scripts
  • Emoji script

#4 @joedolson
2 months ago

  • Milestone Awaiting Review → 7.2

This ticket was mentioned in ​PR #13959 on ​WordPress/wordpress-develop by ​@vidugupta.


12 days ago
#5

  • Keywords has-patch added

Problem

A few first-party admin scripts still carry workarounds for Internet Explorer, which WordPress no longer supports:

  • heartbeat.js falls back to the IE10-only msHidden / msvisibilitychange Page Visibility API.
  • customize/controls.js guards populateChangesetUuidParam() against IE9, which lacks history.replaceState.
  • dashboard.js exits autoResizeTextarea() early when document.documentMode < 9 (IE8 or older).

Root Cause

These fallbacks were added when IE9 to IE11 were supported browsers. IE is now outside the supported browser baseline (browserslist in package.json lists only current Chrome, Firefox, Safari, Edge, Opera and mobile browsers), so the branches can never run in a supported browser. The standard APIs they replaced (document.hidden, history.replaceState, modern layout) are available in every supported browser.

Solution

  1. heartbeat.js: removed the msHidden IE10 branch and dropped "IE < 10" from the comment above it. The webkitHidden branch is kept, because it is for older Android and not IE.
  2. customize/controls.js: removed the if ( ! history.replaceState ) { return; } guard and its comment.
  3. dashboard.js: removed the document.documentMode early exit and its comment.

Not included, and left for separate tickets:

  • Vendor files (imgareaselect, thickbox).
  • The Gruntfile.js compatibility: 'ie11' setting.
  • The -ms- rules in forms.css, some of which Chromium Edge still uses.
  • The TinyMCE ie7/ie8/ie9 body classes.
  • The "IE11" timezone fallback in dashboard.js, which may serve other cases.

Example Usage

// BEFORE: IE-only branch in the Page Visibility detection.
} else if ( typeof document.msHidden !== 'undefined' ) { // IE10.
        hidden = 'msHidden';
        visibilitychange = 'msvisibilitychange';
        visibilityState = 'msVisibilityState';
} else if ( typeof document.webkitHidden !== 'undefined' ) { // Android.
// AFTER: the standard API is used, with the Android fallback kept.
} else if ( typeof document.webkitHidden !== 'undefined' ) { // Android.

Impact

  • No behavior change in any supported browser.
  • Removes 15 lines of dead code and one stale browser reference from a comment.
  • Checked: npx eslint passes on all three files, and no QUnit test references the removed code.
  • Not checked locally: the QUnit suite could not run, and I did not manually test Heartbeat, the Customizer changeset_uuid URL parameter or the Dashboard widgets in a browser. Please verify those in review or CI.

Trac ticket: https://core.trac.wordpress.org/ticket/NNNNN
Parent: https://core.trac.wordpress.org/ticket/64278

Note: See TracTickets for help on using tickets.