Problem/Motivation

Currently, the COOKiES library is depending on jQuery.
Drupal core and many contrib modules are moving away from jQuery to vanilla JS. See: #3052002: [meta] Replace JQuery with vanilla Javascript in core

What are your plans regarding jQuery in this module?

Ideally, we won't need jQuery any more but I guess, the reality might be a bit more complicated than that. :)
So, I suppose, things to consider are:

  • pros and cons of jQuery vs vanilla JS. (Developer experience, performance, features, ...)
  • how much refactoring both COOKiES' core JS and depending sub modules will need to make the transition work.

Proposed resolution

TBD.

Remaining tasks

- [] Remove jQuery
- [] Use ES6
- [] Optimize JS (esLint)

User interface changes

TBD.

API changes

TBD.

Data model changes

TBD.

Issue fork cookies-3225233

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

design.er created an issue. See original summary.

anybody’s picture

Thank you @design.er for raising this discussion. Good point!

Let's see what @JFeltkamp says, I'll also have a look at this if I can help.

jfeltkamp’s picture

Of course a good point. We should remove jQuery and continue with pure JS.

design.er’s picture

Category: Support request » Plan

That sounds great!

Some initial thoughts and questions ...

Versioning

Would it make sense to ship a COOKiES version 2.0 with vanilla JS?
That way depending COOKiES sub modules and users could keep using version 1 if they have custom jQuery-based COOKiES code on their sites and upgrade to version 2 when they're ready to ditch the jQuery dependency.

Version 2 would receive new features. The question is, (for how long) would version 1 still receive security fixes or be dropped all together?

Would version 2 be an opportunity to introduce additional (api, functional, visual) features and changes?
How complex would be an upgrade path from version 1 to 2.

Modal dialog

Drupal core is planning to replace the jQuery UI modal dialog with another technology. #2158943: Add a native dialog element to deprecate the jQuery UI dialog
Wouldn't it be great if it were possible to use the new core modal for COOKiES 2 to off-load COOKiES' development time? Maybe it's a good idea to get in touch with the responsible core maintainers in the linked issue and ask some critical questions?

If all of this is way to complicated, forget everything I just said. :)
I'm excited to read YOUR thoughts and ideas. :)

jfeltkamp’s picture

Category: Plan » Task

I think we don't have to release a new major version.
Users can use jQuery as long they want to.
We just have to care about this: If they don't use jquery, jquery shouldn't come in as a dependency of COOKiES.

Nice to hear that dialog soon will work without jQuery UI. It is real heavy. I didn't use it for long time because it's loading so much JS.
But the dialog loads and displays Drupal content (nodes or other pages). Unfortunately, that doesn't help us.

design.er’s picture

I think we don't have to release a new major version.
Users can use jQuery as long they want to.

That's great!

But the dialog loads and displays Drupal content (nodes or other pages). Unfortunately, that doesn't help us.

What a bummer. I was hoping it's possible to load custom (COOKiES) content in the modal dialog. It was worth a shot. :)

Are there any 3rd party COOKiES modules that require jQuery? If so, it would probably make sense to inform those module maintainers about the transition so that they can catch up?

anybody’s picture

Agreed with @JFeltkamp in #5. Cookies brings its own "modal" which is not a real modal and for god's sake not a horrible Drupal Core Modal ;)

Removing jQuery as dependency from COOKiES sooner or later makes sense. I created an issue fork for that. Feel free to start coding and testing.

anybody’s picture

Are there any 3rd party COOKiES modules that require jQuery? If so, it would probably make sense to inform those module maintainers about the transition so that they can catch up?

No I don't think so yet. Only eTracker and it removed jQuery itself in an issue. Could you create a MR @design.er?

anybody’s picture

Title: Remove jQuery dependency? » [2.x] Remove jQuery dependency and use ES6
Version: 1.0.x-dev » 1.1.x-dev

Let's plan this for 2.x with vue!

anybody’s picture

Issue summary: View changes

JavaScript can be optimized in many parts, for example the for loops like here in core: https://git.drupalcode.org/project/drupal/-/commit/f1e33ca3d84ac2251aed1...

But I hope esLint will help a lot! :)

anybody’s picture

Title: [2.x] Remove jQuery dependency and use ES6 » [PP-2.x] Remove jQuery dependency and use ES6
Status: Active » Patch (to be ported)
anybody’s picture

Status: Patch (to be ported) » Postponed

Fixing wrong status

anybody’s picture

Version: 1.1.x-dev » 2.x-dev
Status: Postponed » Active

Hey ho, let's go! 2.x branch was recently created. Please help to implement this or if you're not a developer, please sponsor some development hours.

anybody’s picture

Title: [PP-2.x] Remove jQuery dependency and use ES6 » [2.x] Remove jQuery dependency and use ES6