I need to use a different jQuery version. Currently, Drupal is using jQuery 3.2.1, but I need a previous version.
In Drupal 7 you could easily change jQuery version with the jQuery Update module. How can I achieve the same with Drupal 8?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI need to use a different jQuery version. Currently, Drupal is using jQuery 3.2.1, but I need a previous version.
In Drupal 7 you could easily change jQuery version with the jQuery Update module. How can I achieve the same with Drupal 8?
Add your custom jQuery library in your mytheme.libraries.yml:
jquery-custom:
remote: https://github.com/jquery/jquery
version: "2.2.4"
license:
name: MIT
url: https://github.com/jquery/jquery/blob/2.2.4/LICENSE.txt
gpl-compatible: true
js:
js/jquery-2.2.4.min.js: { minified: true, weight: -20 }
Then override the core jQuery library in your mytheme.info.yml:
libraries-override:
# Replace an entire library.
core/jquery: mytheme/jquery-custom
jquery-2.2.4.min.js
file and placed it in your my_theme/js/
dir. Also, this will not work in a module, only in a/the theme.
May 3, 2021 at 16:48
Re from: Drupal 8 theme showing Uncaught TypeError: $(…).find(…).once is not a function in console >
This shouldn't be an issue in newer versions of Drupal but just in case anyone stumbles upon this like me: After @GiorgosK's answer I changed my
once('drop-render', '.form-item-field-myfield-value-min', context).each(function () {
});
to
$(once('drop-render', '.form-item-field-myfield-value-min', context)).each(function () {
});
and it worked beautifully.