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

CommentFileSizeAuthor
#25 3194543-25.patch34.72 KBJeroenT
#13 3194543-14-minified.patch102.92 KBJeroenT
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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ahaomar created an issue. See original summary.

svenryen’s picture

Category: Bug report » Feature request

I'm reclassifying this as a feature request, since it's not really considered a bug that the script is not minified.

reszli’s picture

probably 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)

eu_cookie_compliance:
  version: VERSION
  js:
    js/eu_cookie_compliance.js: { attributes: { defer: true } }
  dependencies:
    ...

so it probably won't be possible to aggregate it with the rest, but it could be minified nonetheless

reszli’s picture

I 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?

svenryen’s picture

No, I don't have any strong preference for tool to generate the minified version.

selinav’s picture

Hello,

Will it be available in a future version ?

Best regards

Rajeshreeputra made their first commit to this issue’s fork.

svenryen’s picture

@selinav not a high priority right now, but when we finally get around to a version 2, this will be addressed.

svenryen’s picture

Status: Active » Postponed
svenryen’s picture

Status: Postponed » Active

JeroenT made their first commit to this issue’s fork.

JeroenT’s picture

FileSize
102.92 KB
JeroenT’s picture

Status: Active » Needs review

For now, I created a patch that replaces the js file with a minified version.

svenryen’s picture

Thanks @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?

JeroenT’s picture

I've added an npm command that minifies the js file.

svenryen’s picture

Thanks! I'll take a look and merge.

svenryen’s picture

Status: Needs review » Needs work

@JeroenT, on my installation with a fairly default setup I get this error in Console and no banner is shown:

Uncaught TypeError: Cannot read properties of undefined (reading 'o')
    at eu_cookie_compliance.min.js?v=8.9.20:1:54
    at eu_cookie_compliance.min.js?v=8.9.20:1:19849

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?

guardiola86’s picture

I'm getting the same error as @svenryen after applying the changes

JeroenT’s picture

Status: Needs work » Needs review

I made some changes to the script that generates the JS file. Let's see if that works better.

svenryen’s picture

Thanks for the work. I'll tag @DropSolid for a check if the APIs still function with the script minified.

svenryen’s picture

Status: Needs review » Needs work

I 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.

JeroenT’s picture

FileSize
34.72 KB

I've created a patch that works with 8.x-1.22.

  • svenryen committed 80ae613 on 8.x-1.x authored by JeroenT
    Issue #3194543 by JeroenT, svenryen, Rajeshreeputra, reszli, ahaomar,...
svenryen’s picture

Status: Needs work » Fixed

@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.

Status: Fixed » Closed (fixed)

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