Make template.js smaller Currently: 1.2MB

Created on 1 August 2023, over 1 year ago
Updated 4 August 2023, over 1 year ago

Problem/Motivation

The template js includes a lot of SVGs that are adding a lot of weight to the templates.js file. Also I'm not 100% sure mixing Apache 2 assets and releasing code with GPL v2 is compatible. I know it is compatible with GPL v3, but not sure with v2.

Proposed resolution

Remove all the SVGs and rely in CSS and another library for the icons.

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇷Argentina dagmar Argentina

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dagmar
  • Assigned to vincent.hoehn
  • 🇩🇪Germany vincent.hoehn Dresden, Germany

    Hi @dagmar, thank you for your feature request!

    The size of the file is huge, unfortunately. We were faced with the problem of how to make icons available to users. Through the build process, the icons are included in the file. So if a user wanted to use their icons, they would have to rebuild the file. We didn't want to do that.
    Then we came up with the idea of including an icon set. This way, the choice for each user is huge. The advantage of the choice of icons won out over the disadvantage of the file size.

    You are right about the license. GPL v2 is not fully compatible with the Apache 2 license!

    What would you prefer for a solution? A different icon set with a different/compatible license and fewer icons?

  • 🇦🇷Argentina dagmar Argentina

    What about adding the SVG content instead of the path to an icon as part of the json?

    [
        {
          "title": "Link",
          "icon": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>
    ',
          "description": "Insert a link to the Drupal CKEditor5 project site.",
          "html": "<p>Do you know this cool <a href='https://www.drupal.org/project/ckeditor5' target='_blank'>editor</a>?</p>"
        },
        {
            "title": "Simple Table",
            "icon": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>
    ',
            "description": "Insert a simple Table.",
            "html": "<table border='1'><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr><tr><td>Row 1, Column 1</td><td>Row 1, Column 2</td><td>Row 1, Column 3</td></tr><tr><td>Row 2, Column 1</td><td>Row 2, Column 2</td><td>Row 2, Column 3</td></tr><tr><td>Row 3, Column 1</td><td>Row 3, Column 2</td><td>Row 3, Column 3</td></tr></table>"
        }
      ]
    
    
    • vincent.hoehn committed d2a623c9 on 1.0.x-feature/3378579
      Issue #3378579:  Check if json contains an svg or a description. If not...
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany vincent.hoehn Dresden, Germany

    Thank you very much, dagmar. I have implemented the functionality. This allowed us to reduce the size of the template.js to 2.06KB! Can you take a look at the branch 1.0.x-feature/3378579?

  • Status changed to Fixed over 1 year ago
  • Status changed to Fixed over 1 year ago
Production build 0.71.5 2024