ErHaWeb / klaro_consent_manager

TYPO3 integration of Klaro! Consent Management. Klaro! is a powerful tool that protects the privacy and data of your visitors and helps you run a GDPR compliant website.
Other
1 stars 0 forks source link

add data-ignore attribute and dynamic configuration #11

Open AnutLinruesri opened 3 weeks ago

AnutLinruesri commented 3 weeks ago

In TYPO3 v12, Klaro doesn't work well with JavaScript compression, particularly when using the Scriptmerger extension.

Is it possible to add a data-ignore attribute to the configuration so that it is ignored during JavaScript compression?

File Path: Classes/EventListener/KlaroJavaScript.php https://github.com/ErHaWeb/klaro_consent_manager/blob/main/Classes/EventListener/KlaroJavaScript.php

Line: 64

foreach (($settings['javascript'] ?? []) as $key => $javascript) {
    if (!($asset[$key] ?? false) && $javascript) {
        if ($key === 'klaro-default') {
            $attributes['data-klaro-config'] = $configuration['config_variable_name'];
            $attributes['data-ignore'] = 1;
        }
        $event->getAssetCollector()->addJavaScript($key, $javascript, $attributes, ['priority' => true]);
    }
}
ErHaWeb commented 3 weeks ago

Thanks for the report. I will have a look at the problem in conjunction with scriptmerger after my holiday. I have not dealt with scriptmerger yet but I think it would be better if the compression works instead of deactivating it, wouldn't it?

ErHaWeb commented 2 weeks ago

I have now tested the sgalinski/scriptmerger extension (version 9.0.1) in TYPO3 12.4.19 both with and without the Klaro extension. Regardless of whether the klaro extension is installed or not, Scriptmerger currently seems to issue a JavaScript error Uncaught SyntaxError: illegal character U+001F. Is this the error you are referring to? Since this error always occurs when any JavaScript is included that is compressed by the scriptmerger extension, the problem seems to lie with scriptmerger itself. Can you confirm this?