- Issue created by @poker10
- ๐ฉ๐ชGermany jan kellermann
In original documentation of klaro-js the loading with "defer" is recommended.
We run in some race-conditions with our own drupal integration and removed the defer-flag.We will check this again - unfortunately, the impact assessment is not trivial.
- ๐ฉ๐ชGermany jurgenhaas Gottmadingen
When removing
klaro
as a function argument in line 1, this causes follow-up issues, e.g. in line 15, line 39 and below, where the klaro object is being referenced. I'm not sure how that can be resolved. Tha browser console prints error messages "klaro is not defined". - ๐ฉ๐ชGermany Anybody Porta Westfalica
FYI: I think
defer
would be the right choice logically and based on our experiences with COOKiES. Still if claro is loaded at the end of the page, the effect should be minimal.
See similar comments here: ๐ COOKiES increases LCP a lot (Google pagespeed) Active - ๐ฌ๐งUnited Kingdom catch
Does the Klaro Drupal js need to be set to preprocess: false and also set to defer to match? Then the browser should still load the klaro library first, which would mean all the js ought to continue to work then.
- ๐ฉ๐ชGermany jan kellermann
Yes, I suppose. This is on our list of measures. However, this also delays the rendering of the contextual content dialogs - which probably leads to a worsening of the LCP e.g. for a YouTube video on the start page.
- ๐ฌ๐งUnited Kingdom catch
I personally would not be too worried about making LCP of a youtube video worse, because it's already bad, and using something like https://www.drupal.org/project/lite_youtube_embed โ would make it much better, and mean that third party js would only be loaded when it's interacted with, not when the page is loaded.
No idea how that module interacts with Klaro though, if it blocks the lite youtube render too, then that'd be trickier.
Also all the pages without a youtube embed would be faster anyway.
-
jan kellermann โ
committed 8e559228 on 3.x
#3493822: Defer loading of library.
-
jan kellermann โ
committed 8e559228 on 3.x
- ๐ฉ๐ชGermany jan kellermann
Thank you for feedback and testing.
I merged the code.
- ๐ฉ๐ชGermany Anybody Porta Westfalica
Great work @jan kellermann thank you!!
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
6 days ago 12:35pm 18 April 2025 - ๐ฎ๐นItaly antonio.bertolini
Hi all,
at line 47 of klaro.drupal.js// Store reference to manager once. if (!Drupal.behaviors.klaro.manager) { Drupal.behaviors.klaro.manager = klaro.getManager(Drupal.behaviors.klaro.config); //<--- HERE }
I've
Uncaught ReferenceError: klaro is not defined
.Any ideas?
- ๐ฎ๐นItaly antonio.bertolini
My bad.... incomplete library install...
Sorry!!!!!!
The patch works correctly!Antonio