Hi,

I work with a lot of projects, that don't use jQuery as dependency as it is rather outdated nowadays and just yet another dependency that can cause conflicts. Therefore I'd like to propose a removal of jQuery in this project.

I hope I can find some time myself in the next few weeks to provide you with a patch.

What are your thoughts on it?

EDIT:
We should aim for an ES6 rewrite on a 2.x branch, see https://www.drupal.org/project/eu_cookie_compliance/issues/3130662

Comments

arthur_lorenz created an issue. See original summary.

Snehal Brahmbhatt’s picture

Status: Active » Needs review
StatusFileSize
new601 bytes

@arthur_lorenz, Here's the patch as per the requested changes mentioned above, I removed the jquery dependency from libraries.yml

Status: Needs review » Needs work

The last submitted patch, 2: eu-cookie-compliance-3023845-2.patch, failed testing. View results

arthur_lorenz’s picture

@snehal.addweb thx, but this is actually not what I want to have. I want the js file to be modified, so no jQuery function is used anymore.

arthur_lorenz’s picture

Assigned: Unassigned » arthur_lorenz
svenryen’s picture

Status: Needs work » Needs review
svenryen’s picture

Status: Needs review » Needs work

No, we definitely can't use that patch :)
It's a monumental task though, to remove reliance of jquery, and it would have to be done for both d7 and d8.

arthur_lorenz’s picture

StatusFileSize
new34.74 KB

Had some spare time and I created this first attempt of removing jQuery dependency from the d8 module. This will most likely need some testing and refinement, but it seems to work for me.

arthur_lorenz’s picture

Status: Needs work » Needs review
arthur_lorenz’s picture

StatusFileSize
new35.71 KB

Got the chance to test it on IE11, had to fix some issues to get it to run, but now it seems to run flawless.

arthur_lorenz’s picture

norman.lol’s picture

Assigned: arthur_lorenz » Unassigned
norman.lol’s picture

svenryen’s picture

We need a patch for Drupal 7 before we can add this to the dev branch.

norman.lol’s picture

Why is that? Because of feature equality?

svenryen’s picture

Yes. It will be really hard to maintain a stable module and offer equal support to 7 and 8 if the scripts are vastly different.

svenryen’s picture

I'm going to change my mind on that, and start adding features to 8.x without requiring a backport to 7.x.

Luckily the patch still applies, I'll do some testing and try to commit this later.

svenryen’s picture

Status: Needs review » Needs work

I gave the code a go, and it fails with the cookie categories feature. There's an error thrown when the module tries to read the json saved in the [cookie-name]-categories cookie.

I didn't test it further. If you could look into that it would be great. I will return to this, but there's a lot of open issues at the moment.

arthur_lorenz’s picture

Status: Needs work » Needs review
StatusFileSize
new36.62 KB

Awesome.

Sry seems like i tested it only properly with default configuration. Fixed issues with categories, this should work now. Also found some bugs of withdraw-popup animation and fixed it. I hope this is fine now.

svenryen’s picture

Thanks. I'll have a look later.

anybody’s picture

Whatever we'll do here, this is definitely a candidate for a separate branch! The patch is quite large and will require very many rerolls over time, whenever other issues are fixed.
That costs a lot of volunteers time nobody here likes to invest, I guess.

So if this is an option, it should become a separate 2.x branch which then requires all other issues to be also fixed there, but keep things separate and clean.

I'd suggest to first have a sprint in 8.x-1.x to create a new stable release with all important RTBC'd patches, wait for some weeks for regression issues and then create a separate branch and proceed there as quickly as possible to prevent duplicate issues.

BTW I don't think it will make sense to backport that to D7 because of EOL!

arthur_lorenz’s picture

2.x branch is a good idea, also we could introduce proper es6 style. That would make my patch irrelevant, but the result would be much nicer.

thomas.frobieter’s picture

arthur_lorenz’s picture

Issue summary: View changes
Status: Needs review » Needs work

Awesome, I'll set this on "needs work" then and update the description

christian.wiedemann’s picture

The setCookie did not set the options to the cookie. I fixed that and rerol it for the latest dev.

christian.wiedemann’s picture

StatusFileSize
new36.39 KB
purushotam.rai’s picture

Status: Needs work » Needs review
StatusFileSize
new38.61 KB
new3.64 KB

Patch #25 does not work for me, probably because I'm using 8.x-1.9

But apart from that, patch 25 does not cover all the changes of #19, check line 314 of the patch. Probably it was missed. PAtch 25 does good job of adding cookie options properly.

I also noticed some important bugs of Patch 19, which creates functional problems, specially the cookie removal process.
Adding interdiff wrt Patch 19 as well, for better visibility.

norman.lol’s picture

@purushotam.rai – So is your patch now against latest dev or against 1.9?

purushotam.rai’s picture

It's 1.9 as of now.

norman.lol’s picture

Thank you for clarification. Do you see any chance to create the patch from the latest dev to let the tests run and let others review it properly and enable the maintainers to apply and push it?

svenryen’s picture

Thanks all for the monumental work being done in this issue.

Just heads up - we have a lot of patches going into -dev these days, so you may need to do multiple re-rolls to catch up.

I see a lot of setting the status to "Needs review", though it would be useful if somebody has time to test all features (or even better, start writing tests) with this patch applied so that we know we're not breaking any part of the module when we remove jQuery.

svenryen’s picture

Status: Needs review » Needs work

The patch needs a re-roll (though it's probably a good idea to hold off for now).

svenryen’s picture

I'd like to ask a question about the Javascript in this module, as I see there keeps being some movement in this issue.

If you had the choice, would you rather help restructure the javascript so that it's more object oriented and easier to maintain in the long run, or do you prefer to move the script from #27 to 2.0.x and then maybe stripping away some of the functionality that we don't want to bring forward to 2.0.x?

anybody’s picture

Hi svenryen,

from my perspective 2.x should definitely be a complete rewrite and we should not copy any code, just learn from 1.x what worked well and what didn't. For the JS part that means for me, that we should focus on API thinking and split into general logic (API / model) which could even be controlled from outside, for example by third party modules (a concrete example would be to have a module adding a layer to (de)select categories or add options to the privacy policy to opt in / out, etc.).

In the eu_cookie_compliance logic these general functionalities are also simply called ("business logic"). There are several cases in the issue que where the problem was, that the current code was too complex and had side-effects to allow calls from extending modules.

This would help a lot to improve the readability & testability of the code and allow easier integration and modification.

My two cent ;)

svenryen’s picture

Title: Remove jQuery dependency » [2.0.x] Remove jQuery dependency
sittard’s picture

I'd be happy to help test this and get this much needed feature into 2.x. But unfortunately the current patch does not apply to 1.14 or dev. Any chance this patch could be updated so we could review it.

Thanks.

svenryen’s picture

I think it's fair to say we will need to rewrite the javascript in version 2 (mainly because it's grown out of hand with all the patches we've accumulated over nearly a decade), so making this patch apply to 1.x may not be the best way to allocate resources (although you're welcome to spend time on that if you wish as it could be a valuable patch for those on 1.x that would like to remove jquery).

svenryen’s picture

Status: Needs work » Closed (outdated)

I'm closing this issue as the script will be rewritten in 2.x and we won't need this patch.

Though thanks a lot for the effort that went into this issue.

loominade’s picture

StatusFileSize
new34.84 KB

for anyone who might need it, here's a patch for 1.9

svenryen’s picture

Status: Closed (outdated) » Active
atowl’s picture

Status: Active » Fixed

Hi All,
going to close this as i've done a pile of work in https://www.drupal.org/project/eu_cookie_compliance/issues/3552718 to remove the current jquery.

it's still in beta testing, but i think it covers most aspect of what the module needs to do.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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