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.
#315100: Allow to add JS/CSS libraries (sets of files, settings, and dependent libraries) allowed modules to register sets of JavaScript/CSS libraries. The problem is that it's not cached. This means that if a contributed module did something really expensive with the registry, like searching for libraries on the harddrive, or did a complex alterations of them, it could potentially be a big performance hit. This issue is to cache that registry so that we don't run into these performance implications.
Comment | File | Size | Author |
---|---|---|---|
#4 | 510334.patch | 5.91 KB | RobLoach |
drupal.get_.library.cache_.patch | 5.58 KB | RobLoach | |
Comments
Comment #1
sunOn one hand, you're right that there might be a module that performs heavy actions to alter libraries. Libraries API might be a good example. On the other hand, a module like that most probably has to perform many other additional actions anyway, so it needs it separate caching (and controlled cache flushing) anyway.
Usage of $name leads to a PHP notice here.
Comment #2
sunTagging.
Comment #3
RobLoach#505084: Add #attached_library FAPI property for drupal_add_library()
Comment #4
RobLoachUpdates to HEAD, takes sun's note about the $name into account and fixes a namespace issue.
Comment #5
mfer CreditAttribution: mfer commented/me subscribes
Comment #7
lilou CreditAttribution: lilou commentedHEAD is broken.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedReally expensive libraries can use own caching. We have to end the cache explosion soon. -1.
Comment #9
RobLoachMoshe, what about modules that regex a file to find out what version of the library they have? To improve the developer experience (modules wouldn't have to cache the data themselves), as well as improve performance (calling a number of module hooks which could do expensive things like regex an opened file), we could just easily cache the library array.
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedNeither of those arguments is compelling. Adding caches rarely improves developer experience. You then have to understand what cache to clear when you are developing and debugging ... Further, the performance gain here is insignificant. It *only* could happen for an expensive operation when its module author cannot be bothered to do own caching.
This is a speculative cache. It might help under certain circumstances that are theoretical. Drupal has enough caches without implementing speculative ones.