Problem/Motivation
In our project, we are working on a JS refactor to improve performance and we have detected that colorbox libraries are globally loaded in all pages even though it is not being used in all of them.
Proposed resolution
Change the way of loading libraries to detect if they are needed.
Comments
Comment #2
jody lynnI am also seeing the library loaded globally. Is this a bug in how the library is being attached?
Comment #3
jody lynnCancel that. This was a self-inflected wound on this project in my case, not a colorbox issue
Comment #4
paulocsI don't see any way how to reproduce this issue. I debug the code and I notice that the library is attached in the
ColorboxFormatter::viewElements()function:This function is called when the field is rendered only. So the library is not loaded in all pages by the module...
See also: https://git.drupalcode.org/project/colorbox/-/commit/a3b5e85f901e0b668e56f3277843f3102c3a9e5b
Comment #5
renatog commentedYeah, really makes sense. I think it's ok. I recommend only make sure that you're using the last version and try to clear all cachess and turn-on the minification on JS
Thank you so much everyone