Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS Cookie library deprecated in Drupal 10.1, removed in Drupal 11 without replacement #271

Open
andybroomfield opened this issue Jul 17, 2023 · 6 comments

Comments

@andybroomfield
Copy link
Contributor

The core/js-cookie asset library is deprecated in Drupal 10.1.0 and will be removed in Drupal 11.0.0. There is no replacement. See https://www.drupal.org/node/3322720

So does this mean we need to declare a dependancy on it directly and ask users to download it to the libraries folder? Or just include a copy.

@keelanfh
Copy link
Member

... or refactor the code to remove the dependency, could be done at the same time as removing the jQuery dependency (#201)

@millnut
Copy link
Member

millnut commented Oct 13, 2023

I would probably recommend using vanilla javascript and then switching out cookies in favour of localstorage.

@siliconmeadow
Copy link
Member

On the 4 Apr 2024, they updated that change record with a solution to switch to a contrib module which is unsurprisingly called JS Cookie. It's maintained by Dave Reid who is prolific.

@markconroy
Copy link
Member

That js-cookie module just does one thing: get the js-cookie JS from https://github.com/js-cookie/js-cookie so that it can be used in a Drupal site.

I think the simplest thing is to update our .libraries.yml file to fetch that JS file for us and then we don't need to worry about needing the Drupal module.

===
Thanks to Big Blue Door for sponsoring my time to work on this.

@andybroomfield
Copy link
Contributor Author

Tthe current plan given we don't use many of the features, just set and read back a cookie, is to try and remove the dependency. @millnut is trying to switch to local storage in #322.
I really would like to avoid having sites load a Javascript file from a CDN.

@markconroy
Copy link
Member

What's the thinking behind using localStorage instead of a cookie?

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

No branches or pull requests

5 participants