Problem/Motivation

Since 3.5, CustomElement::setSlotFromRenderArray() adds a <drupal-library-*> element for every JavaScript library a render array attaches. Sites whose frontend does not load Drupal's JavaScript get a larger payload and unknown elements, and cannot turn this off.

Proposed resolution

Add a boolean library_elements to custom_elements.settings, off by default, and emit library elements only when it is on.

Remaining tasks

  • Review.

User interface changes

A checkbox in the Custom Elements settings form.

Data model changes

New configuration key library_elements, with an update for existing sites.

AI disclosure

This issue and the patch were drafted with AI assistance (Claude Code). I reviewed and tested the change before posting.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fago created an issue. See original summary.

fago’s picture

Issue summary: View changes

fago’s picture

Issue summary: View changes
Status: Active » Needs review
fago’s picture

the MR adds the settings, tested and reviewed, all good!

fago’s picture

This also adds docs for the feature in README. I improved it a bit. all good now.

  • fago committed 886a1c6c on 3.x
    task: #3638044 Add a setting to opt-in to JavaScript library elements...
fago’s picture

Status: Needs review » Fixed

merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.