Problem/Motivation
Pages where multiple editor instances are loaded would benefit from static caching. Currently, Drupal\editor\Plugin\EditorManager::getAttachments()
is called for every editor instance, which is inefficient, avoidable, and results in slow page load times if more than a few editor instances are loaded.
A real-world example would be a node edit page with a number of CKEditor 5-enabled fields. This is actually fairly common on sites build with Paragraphs.
Steps to reproduce
- Install vanilla Drupal with the 'Standard' install profile.
- Modify the Body field on the Article content type to allow unlimited values.
- Create an Article node with 20 values for the Body field.
Proposed resolution
- On the
EditorManager
class, add an$attachments
property and an$editors
property. - In the
::getAttachments
method, refactor the code to cache editors and attachments such thateditor_load()
is only called once per editor.
Remaining tasks
Open MRCode review- Merge
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
TBD.
Original Issue Summary
We have nodes with paragraphs which contain ckeditor 5 instances.
Now i know i could load the paragraphs in a closed state but this is not what we're doing.
We're currently optimizing the author performance and benchmark the application with Blackfire and saw that a lot of code is executed for each instance of Ckeditor which i think we should be able to cache for each text editor format?
See the attachments of the timeline and the zoom into the getAttachments functions which i think we should be able to statically cache for each text editor format?