Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Working on Google page speed so found eu_cookie_compliance.js is not minified. Even with drupal core minified and Advagg module is not not minified
how we can minified that js ?
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#25 | 3194543-25.patch | 34.72 KB | JeroenT |
#13 | 3194543-14-minified.patch | 102.92 KB | JeroenT |
Issue fork eu_cookie_compliance-3194543
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
Comment #2
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedI'm reclassifying this as a feature request, since it's not really considered a bug that the script is not minified.
Comment #3
reszliprobably has to do with the fact that it is deferred, so Advagg will not pick it up: https://www.drupal.org/project/advagg/issues/3072469 (also related https://www.drupal.org/project/drupal/issues/1587536#comment-13852581)
so it probably won't be possible to aggregate it with the rest, but it could be minified nonetheless
Comment #4
reszliI guess this would be like having both the original (un-minified) and the minified version in the repo, but include the minified one in the library with the {minified: true} flag
the minification needs to happen on every change, will be part of every patch / MR which changes the original file
@svenryen do you have a specific process / tool in mind to obtain the minified version?
Comment #5
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedNo, I don't have any strong preference for tool to generate the minified version.
Comment #6
selinav CreditAttribution: selinav commentedHello,
Will it be available in a future version ?
Best regards
Comment #8
svenryen CreditAttribution: svenryen at Ramsalt Lab commented@selinav not a high priority right now, but when we finally get around to a version 2, this will be addressed.
Comment #9
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedComment #10
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedComment #13
JeroenTComment #14
JeroenTFor now, I created a patch that replaces the js file with a minified version.
Comment #15
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedThanks @JeroenT - what tool do you use for the minifying? We would need to distribute the un-minified version as well so that people can contribute. Could you create a task runner and a setup for generating a minified script?
Comment #16
JeroenTI've added an npm command that minifies the js file.
Comment #17
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedThanks! I'll take a look and merge.
Comment #18
svenryen CreditAttribution: svenryen at Ramsalt Lab commented@JeroenT, on my installation with a fairly default setup I get this error in Console and no banner is shown:
Also, how would this apply to the module's events API and functions that other modules and sites leverage such as the hasAccess(category) function?
Could you take a look?
Comment #19
guardiola86 CreditAttribution: guardiola86 at Full Fat Things commentedI'm getting the same error as @svenryen after applying the changes
Comment #20
JeroenTI made some changes to the script that generates the JS file. Let's see if that works better.
Comment #23
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedThanks for the work. I'll tag @DropSolid for a check if the APIs still function with the script minified.
Comment #24
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedI wonder if we have a regression and the API isn't working any longer. I wasn't able to make the API work in the non-minified state when following the example in the readme file from the module, so I doubt the API calls would work when minified. Anyways this will have to wait till I hear back from DropSolid.
I added the latest code changes to the minified file.
Comment #25
JeroenTI've created a patch that works with 8.x-1.22.
Comment #27
svenryen CreditAttribution: svenryen at Ramsalt Lab commented@JeroenT, you've done a fantastic job!
I can confirm the event API still works with the latest set of files from your issue branch.
I've tested and all seems to work well so I'll commit this to the module and tag a new release.