Problem/Motivation

After we have updated our browser support in #2390621: [policy, no patch] Update Drupal's browser support policy, let's go through our polyfills and determine which browser polyfills are no longer needed.

Proposed resolution

Polyfills that are no longer needed should be deprecated for removal before Drupal 9.

Remaining tasks

Deprecate

#3086379: Deprecate html5shiv and remove usages in core
#3086369: Deprecate matchMedia
#3086375: Deprecate domready and remove usages in core
#2955842: Deprecate classList library

Remove

#3089469: Remove html5shiv in Drupal 9
#3089472: Remove matchmedia in Drupal 9
#3089480: Remove domready in Drupal 9
#3090010: Remove classList in Drupal 9

#3072906: Deprecate and remove jQuery UI datepicker

User interface changes

API changes

Data model changes

Release notes snippet

Comments

lauriii created an issue. See original summary.

xjm’s picture

Title: Remove polyfills that are no longer needed » Deprecate (in 8.8) and remove (in 9.0) polyfills that are no longer needed
Status: Postponed » Active

The policy has all the needed signoffs and is just waiting on docs updates, so this can start now!

zrpnr’s picture

I made a first pass at this, looking over the files in assets/vendor as well as searching for "polyfill" in core.

Polyfills which can be removed

matchmedia

core/matchmedia
core/matchmedia.addListener

Added in: #1815602: Introduce a polyfill for matchMedia

https://caniuse.com/#feat=matchmedia
https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener
Should be supported in IE11 but need additional verification

domready

core/domready
Added in #1974580: Introduce domReady to remove jQuery dependency from drupal.js and clean it up.
Only used in drupal.init.js, could be replaced with event listener
https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded...
suggested to remove in https://www.drupal.org/project/drupal/issues/2961308

html5shiv

core/html5shiv
Added in: #1077878: Add HTML5shiv to core
https://caniuse.com/#feat=html5semantic
This lists issues with the main element in IE11,
I tested the Bartik theme with IE11 and the page seemed to render correctly, and the main element appeared in the dom inspector.
Opera mini treats all semantic elements being "unknown" but "This is easily taken care of by manually setting the default display value for each tag."
Related: #1993334: Add HTML5shiv to Stable and Classy only

Polyfills with open issues to remove/replace

classList

core/classList

Not fully supported by IE11
https://developer.mozilla.org/en-US/docs/Web/API/Element/classList
However none of these usages are in Drupal core

open issue to deprecate core/classList: https://www.drupal.org/project/drupal/issues/2955842

input type=date

core/misc/date.es6.js
Deprecate jQuery UI datepicker
#3072906: Deprecate and remove jQuery UI datepicker

dialog

Polyfill HTML5 dialog element with jQueryUI
core/misc/dialog/dialog.es6.js
Replace jQuery UI dialog with supported library or polyfill
#2158943: Add a native dialog element to deprecate the jQuery UI dialog

Farbtastic, inpu type=color

core/farbtastic
https://www.drupal.org/project/drupal/issues/2268955

postponed on: https://www.drupal.org/project/drupal/issues/1651344
http://caniuse.com/#feat=input-color

Polyfills required by current browser support policy

details

core/misc/collapse.es6.js
Polyfill for HTML5 details elements
used by IE11
https://caniuse.com/#feat=details

Related:
core/themes/seven/css/components/entity-meta.css
https://www.drupal.org/node/2493957

picturefill

Polyfill for picture
https://caniuse.com/#search=picture
https://caniuse.com/#feat=srcset

Related: #1883526: Decide on the picture polyfill to use

zrpnr’s picture

Farbtastic is also related to #2808151: [policy] Move the Color module to a contributed project when Bartik is deprecated, if color module is moved to contrib then farbtastic could be removed from core as well.

zrpnr’s picture

lauriii’s picture

We should deprecate these polyfills from core, but we should keep them in stable to keep sites intact. Instructions on the deprecation notice message should recommend using the library from Stable, or to remove dependency to it altogether. I recommend the following process for each polyfill:

  1. Deprecate the library
  2. Remove it's usages from core
  3. Add a copy of the library to Stable
  4. Load polyfill in Stable

I agree that we can deprecate and remove core/matchmedia, core/domready and core/html5shiv.

core/classList seems like a fairly small polyfill but I think we could continue on deprecating and removing it since it's not needed by core anymore.

Should we deprecate core/farbtastic and add a copy of the library to color module? This might be also an additional justification for #2808151: [policy] Move the Color module to a contributed project when Bartik is deprecated.

xjm’s picture

Thanks everyone! For now, let's consider the Farbtastic discussion a coild-have; it's the same code whether we're moving it (back) into Drupal core or not, and should not affect the BC. We can also do that deprecation during Drupal 9's minors.

Let's go ahead with the deprecations of matchmedia, domready, and html5shiv, and consider at least marking those three deprecated the must-haves to complete by 8.8.0-beta1.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

zrpnr’s picture

Version: 8.9.x-dev » 8.8.x-dev

I added contrib modules to replace these asset libraries at

and updated the domready issue per feedback from @lauriii

lauriii’s picture

In each major release, polyfills that are no longer needed (because all supported browsers have added the feature natively) will be removed.

The policy states that the polyfills that are no longer needed, will be removed as part of a major release. Does this mean that we can remove the polyfill from being loaded before that as part of a minor release, or do we have to keep loading the polyfill by default till the major version ships?

lauriii’s picture

Talked about #12 with @catch and we agreed that the steps we should be taking on the polyfill removals are:

  1. Deprecate the library
  2. Suppress the deprecation in tests
  3. Remove the library and its usages in a major release

This means that the contrib modules will have to be written in a way that ensures that the library isn't loaded twice.

xjm’s picture

I agree with #13.

zrpnr’s picture

html5shiv and matchmedia now are simpler patches, they just add the deprecation message.
domready still removes any usages in core and marks the library deprecated.

I also updated the 2 contrib modules per @lauriii feedback

the contrib modules will have to be written in a way that ensures that the library isn't loaded twice

The change records for html5shiv and matchmedia now have a link to their contrib projects.

xjm’s picture

Title: Deprecate (in 8.8) and remove (in 9.0) polyfills that are no longer needed » [meta] Deprecate (in 8.8) and remove (in 9.0) polyfills that are no longer needed
Category: Task » Plan
xjm’s picture

Version: 8.8.x-dev » 9.0.x-dev

All three polyfills are now deprecated, so all that remains to actually remove them in 9.0.x (probably actually more work). ;)

zrpnr’s picture

Added the 3 child issues for removing these polyfills from Drupal 9, and they all have patches ready for review.

zrpnr’s picture

Issue summary: View changes
Related issues:

The issues to deprecate html5shiv, matchMedia, domready and classList are fixed,
The issue to remove html5shiv is fixed, and matchMedia, domready and classList are RTBC.

Updated the IS.

zrpnr’s picture

Issue summary: View changes

Updated IS now that #3072906: Deprecate and remove jQuery UI datepicker is deprecated in 8.8 and 8.9, and removed from 9.0

gábor hojtsy’s picture

Status: Active » Fixed

All of the children are now done. Congrats and thanks!

xjm’s picture

All child issues have been fixed so we can mark this fixed too. Yay!

xjm’s picture

Uhh and that's me crossposting four days later. Sorry. :D

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.