Problem/Motivation

Splitting this off from #3224261: [PP-2] Front-end performance: concatenate CKEditor 5 JS assets for every unique configuration.

We should enable aggregation for all ckeditor5 assets, this will provide a baseline where we have less HTTP requests but the potential for mostly-duplicated aggregates. #3224261: [PP-2] Front-end performance: concatenate CKEditor 5 JS assets for every unique configuration and/or potentially other issues can then try to improve from there.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch created an issue. See original summary.

catch’s picture

ankithashetty’s picture

Rerolled the patch in #2, thanks!

Wim Leers’s picture

Title: Enable aggregation for ckeditor5 assets » Enable aggregation for CKEditor 5 assets
Status: Needs review » Needs work
Issue tags: +Needs reroll, +front-end performance, +blocker

Manual testing: 🥳

Before
<script src="/sites/default/files/js/js_3f6AdoXJIzKJzozcBSEx3O4Lsr0LtR5J6PDqCGp8MzQ.js"></script>
<script src="/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/language/language.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/editor-classic/editor-classic.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/html-support/html-support.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/editor-decoupled/editor-decoupled.js?v=31.1.0"></script>
<script src="/sites/default/files/js/js_WnGf9r4hVWXVSakVLCqYSNeD-o5zMho9-7cD_MuO_10.js"></script>
<script src="/core/assets/vendor/ckeditor5/basic-styles/basic-styles.js?v=31.1.0"></script>
<script src="/core/modules/ckeditor5/js/build/drupalEmphasis.js?v=9.4.0-dev"></script>
<script src="/core/assets/vendor/ckeditor5/image/image.js?v=31.1.0"></script>
<script src="/core/modules/ckeditor5/js/build/drupalImage.js?r7pst1"></script>
<script src="/core/assets/vendor/ckeditor5/heading/heading.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/essentials/essentials.js?v=31.1.0"></script>
<script src="/core/modules/ckeditor5/js/build/drupalHtmlEngine.js?r7pst1"></script>
<script src="/sites/default/files/js/js_C9cya7gpmllS5d8JGlnvW3QuoAq0nRi4yIFgawfTytA.js"></script>
<script src="/core/modules/ckeditor5/js/build/drupalMedia.js?r7pst1"></script>
<script src="/core/assets/vendor/ckeditor5/block-quote/block-quote.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/link/link.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/list/list.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/paste-from-office/paste-from-office.js?v=31.1.0"></script>
<script src="/core/assets/vendor/ckeditor5/source-editing/source-editing.js?v=31.1.0"></script>
<script src="/sites/default/files/js/js_Y0zfNrRXQ4omiZN6AW4VL6YkoEGl_tMFkTAGQmS30mw.js"></script>
<script src="/core/assets/vendor/ckeditor/ckeditor.js?v=4.17.1"></script>
<script src="/sites/default/files/js/js_GRmKOoYReYJJptbNu9iGok1QTSnvcAryp8m_mvSx9IY.js"></script>
After
<script src="/sites/default/files/js/js_nQtm9zpwk-PrJ2wl0Z0AldpA96w-3UP-ezA8D4cnBqY.js"></script>
<script src="/core/modules/ckeditor5/js/build/drupalHtmlEngine.js?r7pu9q"></script>
<script src="/sites/default/files/js/js_MINxMjLxQhsjQve9n-dob_p2zWdwgmqtCm5-9iUtjr8.js"></script>
<script src="/core/assets/vendor/ckeditor/ckeditor.js?v=4.17.1"></script>
<script src="/sites/default/files/js/js_GRmKOoYReYJJptbNu9iGok1QTSnvcAryp8m_mvSx9IY.js"></script>

Code review

  1. +++ b/core/modules/ckeditor5/ckeditor5.libraries.yml
    @@ -38,21 +38,23 @@ drupal.ckeditor5.quickedit-temporary-work-around:
    +    - core/ckeditor5
    ...
    +    - core/ckeditor5
    

    Are these changes truly necessary? They're implied by their other dependencies?

  2. Needs reroll now that #3228464: API for contrib projects to load CKEditor translations landed.
nod_’s picture

Version: 9.4.x-dev » 10.0.x-dev
Status: Needs work » Needs review
FileSize
9.02 KB

I left ckeditor-dll.js file unaggregated so that all the ckeditor 5 plugins and translations end up in a separate aggregate from the rest of the JS on the page.

kept the added dependencies to core/ckeditor5 since the plugins need the main library to do anything, they do have a dependency on it. Implicit dependencies are bad #3244855: Regression in Drupal 9.3.x due to jQuery.once deprecation :)

Wim Leers’s picture

#5: so … diff-wise … you only changed the very first hunk in the file?

nod_’s picture

That is correct

Wim Leers’s picture

Issue tags: -Needs reroll
  1. +++ b/core/core.libraries.yml
    @@ -30,6 +30,9 @@ ckeditor5:
    +    # This file is not aggregated so that ckeditor5 assets can be grouped
    

    Übernit: s/ckeditor5/CKEditor 5/

  2. +++ b/core/core.libraries.yml
    @@ -30,6 +30,9 @@ ckeditor5:
    +    # @see ckeditor5_js_alter().
    

    Übernit: the trailing period here should be removed.

IMHO #5 is fine, and we can take it further in #3224261: [PP-2] Front-end performance: concatenate CKEditor 5 JS assets for every unique configuration.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

… by which I meant to do this 🤓

catch’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/core.libraries.yml
@@ -30,6 +30,9 @@ ckeditor5:
   js:
+    # This file is not aggregated so that ckeditor5 assets can be grouped
+    # independently of the other scripts.
+    # @see ckeditor5_js_alter().

ckeditor5_js_alter() says it only does this for translations, not for all other assets?

Isn't it just that everything depending on the ckeditor5 library has to be loaded after this file, and because it's not aggregated, that means they get their own aggregate?

I think this is only a docs issue, but it'd be good to be clear what's going on for the next time we try to touch this.

nod_’s picture

Isn't it just that everything depending on the ckeditor5 library has to be loaded after this file, and because it's not aggregated, that means they get their own aggregate?

That is correct, in core currently it means that everything between ckeditor5-dll.js and ckeditor.js (the version4) gets it's own aggregate, when ckeditor4 is removed it's an aggregate for everything after ckeditor5-dll.js (so that includes some toolbar, bigpipe and a few others). Still better than nothing.

nod_’s picture

Fixed the comment, ideally it's a bit more accurate.

Ideally if we could ensure that all the ckeditor 5 libraries are added at the end of the #attached array before it's being processed we could make sure that the aggregation group contains only cke5 files and would make the other aggregate probably more useful. But we don't have a way to alter the position of a library in the #attached array, and i'm not about to add a weight property to the library definition (that would work though), i'd prefer #3232810: [PP-1] Allow setting aggregation groups for js files in library definitions.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Comment is much better thanks.

Yeah I think #3232810: [PP-1] Allow setting aggregation groups for js files in library definitions is worth a proper look next.

Wim Leers’s picture

Patch review

  1. +++ b/core/core.libraries.yml
    @@ -30,6 +30,11 @@ ckeditor5:
    +    # translations, enabled plugins, and the rest of the javascript needed on
    

    s/javascript/JavaScript/

  2. +++ b/core/core.libraries.yml
    @@ -30,6 +30,11 @@ ckeditor5:
    +    # the page
    

    Missing railing period.

  3. … but not marking Needs work because @catch RTBC'd it already :D Should be easy to fix on commit and cherry-pick. Queued tests for 9.3 and 9.4, hopefully those pass too. If the patch needs to be rerolled, then we should fix the two nits above.

Manual test

#4
<script src="/sites/default/files/js/js_nQtm9zpwk-PrJ2wl0Z0AldpA96w-3UP-ezA8D4cnBqY.js"></script>
<script src="/core/modules/ckeditor5/js/build/drupalHtmlEngine.js?r7pu9q"></script>
<script src="/sites/default/files/js/js_MINxMjLxQhsjQve9n-dob_p2zWdwgmqtCm5-9iUtjr8.js"></script>
<script src="/core/assets/vendor/ckeditor/ckeditor.js?v=4.17.1"></script>
<script src="/sites/default/files/js/js_GRmKOoYReYJJptbNu9iGok1QTSnvcAryp8m_mvSx9IY.js"></script>
#12
<script src="/sites/default/files/js/js_4mga7FT7b_S-sIraMGtUX5CmiheSkXq1Wy_sTbCnQ7g.js"></script>
<script src="/core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js?v=31.1.0"></script>
<script src="/sites/default/files/js/js_l3tFjJj9_-_TjRM-Y6wOtSedwELEwZnli5pBYj4zFTU.js"></script>
<script src="/core/assets/vendor/ckeditor/ckeditor.js?v=4.17.1"></script>
<script src="/sites/default/files/js/js_GRmKOoYReYJJptbNu9iGok1QTSnvcAryp8m_mvSx9IY.js"></script>

Looking good, and #12 is indeed better than #4. 👍

  • catch committed f8fed30 on 10.0.x
    Issue #3264512 by nod_, ankithashetty, catch, Wim Leers: Enable...
  • catch committed e2a2b9e on 9.3.x
    Issue #3264512 by nod_, ankithashetty, catch, Wim Leers: Enable...
  • catch committed 47ef665 on 9.4.x
    Issue #3264512 by nod_, ankithashetty, catch, Wim Leers: Enable...
catch’s picture

Version: 10.0.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Fixed the two issues with the comment on commit.

I only copied a patch from another issue to here, so I think I'm fine to commit what's here.

Committed/pushed to 10.0.x, cherry-picked to 9.4.x and 9.3.x, thanks!

See everyone on #3232810: [PP-1] Allow setting aggregation groups for js files in library definitions!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.