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
When setting "Include minimal CSS, I want to style the banner in the theme CSS", leaving further settings empty and not using any Cookie disabling scripts, in the header you will find an empty style-tag as well as an empty script-tag.
Solution
Conditionally render Scripts-tag and Style-tag when there is actual content.
Comments
Comment #2
tassilogroeper CreditAttribution: tassilogroeper at WONDROUS commentedComment #3
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedGood point. Thanks for the patch!
Comment #4
tassilogroeper CreditAttribution: tassilogroeper at WONDROUS commentedSorry, forgot about the JS call to the "euCookieComplianceLoadScripts" function.
Comment #5
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedThanks. I'll take a look later.
Comment #6
DuaelFrHi there!
That's a very good point. Those empty styles and scripts should be avoided when not necessary.
The #4 is almost good except for the following:
You can't do this as there is some unrelated code that should be run after this attachment! (lines 322 to 340)
You should wrap the attachment creation as you did with the previous one.
Comment #7
DuaelFrFixed #6
Comment #9
DuaelFrThe coding standards test failures are not related to the attached patch.
Comment #10
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedWhy is this check really needed? Can we try to avoid that?
Comment #11
Bès CreditAttribution: Bès at Happyculture commentedPatch Reroll on the 8.x-1.3 module version
Comment #13
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedComment #14
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedWe would also need a patch for d7.
Comment #15
Bès CreditAttribution: Bès at Happyculture commentedReroll again
Comment #17
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedComment #18
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedI'm not sure this code on line 357 and 358 in the patch should be excluded when there is no css config. To me this doesn't seem right. Those lines were introduced in #2669028: No cache invalidation when settings change. and are not related to the css issue at hand.
Do you have any details, @Bès or @DuaelFr?
Comment #19
Rodlangh CreditAttribution: Rodlangh commentedPatch Reroll on the 8.x-1.6 module version.
Altered the patch according to the comment by @svenryen. Seems to me the cache tags should always be included?
Added an extra check in the js file: savePreferencesAction method also loads the scripts.
Comment #21
BerdirLooks good now, I think. Agreed that the cache tags need to be outside.
Comment #22
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedThanks for the review. I'll commit later.
Comment #23
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedThere was a script load related to the new categories feature that the patch in #19 didn't cover. I added an additional check there, as I think the script would otherwise fail.
Also, patch parted to D7 is attached.
@Berdir, are you free to review this patch again?
Comment #24
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedComment #27
svenryen CreditAttribution: svenryen at Ramsalt Lab commentedSince the added code in #23 was minimal (barely adding another check on the existence of the function), I'll go ahead and commit these changes. Thanks to all who helped.
Comment #30
DuaelFrThank you for your work on this much useful module! :)