Problem/Motivation
jQuery used to be so awesome and It has been with us since Drupal 5.0!
IE10 was released in 2012 and supported most (all?) of the vanilla javascript that is needed to replace jQuery code.
Using vanilla javascript would allow us to remove jQuery from Drupal core as a dependency.
Proposed resolution
The web is full of great resources for making the switch:
- https://www.evermade.fi/replacing-jquery-native-javascript-projects/
- http://youmightnotneedjquery.com/
- https://www.previousnext.com.au/blog/removing-jquery-from-your-drupal-theme
- https://css-tricks.com/now-ever-might-not-need-jquery/
Remaining tasks
Relevant issues and their status as of Dec 19, 2022
Including the date here as the summaries may go out of date -- but I think it's useful to have here as we have enough tabs open already.
#3145958: [META] Re-evaluate use of Backbone.js in core | This might be relevant to removal of jQuery, it might not. Here's why: Vue is one of the proposed replacements for Backbone. Were Vue available as a library in Core, it may significantly change the way that overall jQuery removal is approached. Some jQuery uses could be more elegantly replaced by Vue vs. a vanillaJS refactoring.Note that that the proposed use of Vue in that issue is as a libary to benefit existing core JS, something that is dependent of the React based built-from-scratch Admin UI decision made in 2017. |
#3167377: Rewrite jQuery .show() and .hide() | This includes a potential approach for dealing with some of the requirements of #3179551: Provide no-library equivalents of common/useful jQuery functions |
#3176423: Add classList methods polyfill for Opera Mini | |
#3176441: JavaScript event handling without a full jQuery dependency | There's no simple replacement for how Drupal core uses jQuery event handling. Help us figure out how to best go about this! |
#3179551: Provide no-library equivalents of common/useful jQuery functions | Determining how to best have access to frequently-used jQuery functionality that do not have simple vanilla replacements |
#3177355: Remove Tabledrag's jQuery dependency |
There’s a working patch for this, but it also happens to raise many implementation questions about how to go about replacing jQuery overall. Feedback is VERY welcome. Even people without tabledrag-specific interests may want to check this out as it is representative of many of the obstacles we'll run into in the no-jQuery efforts.
Patch last updated during 2022. |
Postponed:
#3157328: Use vanilla JS instead of jQuery in path module | Work hasn’t started on this yet, someone can hop on this. A proof-of-concept issue to see if “replace jQuery in *.module” issues will be a good approach. |
Replacements
The total size of helper libraries must be lower than minified jquery which is 88kb today + 0.9kb for jquery once.
library | replacement | size | issue |
---|---|---|---|
once | Vanilla JS | 1.3kb | #2402103: Add once.js to core |
events | TBD | ?? | #3176441: JavaScript event handling without a full jQuery dependency |
ajax | TBD | ?? | [#] |
Total | ?? | (jquery + once: 88.9kb) |