Problem/Motivation
Over at #2254865-37: toolbar_pre_render() runs on every page and is responsible for ~15ms/17000 function calls it is impossible to add the cacheable metadata to the link itself.
Proposed resolution
- Add a new parameter for #theme => links, 'links' property to allow setting cacheability as a CacheableMetadata object (or render array) directly on the link.
Useful:
CacheableMetadata::fromRenderArray($cacheable_render_array)
->applyTo($link);
Or
$cacheable_metadata->applyTo($link);
directly (if using the object route).
Remaining tasks
- Do it
User interface changes
- None
API changes
- API addition to #theme links definition
Comments
Comment #1
wim leersIsn't this what you want?
Comment #2
wim leers(#1 is not what the IS suggests, but AFAICT it's even better.)
Comment #3
wim leersComment #5
wim leersSo this unbreaks HEAD, because now
CommentPostRenderCache::attachNewCommentsLinkMetadata()is being called again, and hence the last user of['#attached']['js']is uncovered.Fixing it.
Comment #7
fabianx commentedThe patches are for #2496399: Comment module's node links' front-end perf-optimizing drupalSettings are missing.
This approach here is for #theme => 'links' and has nothing to do with drupal_pre_render_links().
Comment #21
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #22
smustgrave commentedSince there's been no follow up going to close this one out. If still valid please reopen
Thanks all