Aggregated JS knocked out

Created on 13 February 2024, about 1 year ago
Updated 6 March 2024, about 1 year ago

Problem/Motivation

When Drupal JS aggregation is enabled, some of the sub-modules knock out more scripts than they are meant to. This results in errors or missing functionality on pages.

Steps to reproduce

  1. Enable JS aggregation.
  2. Enable the cookies_instagram module.
  3. View a page with an instagram media item before accepting cookies.
  4. Inspect the page:

On my site, I see the following:

<script id="cookies_instagram_0" src="//platform.instagram.com/en_US/embeds.js" type="text/plain" data-cookieconsent="instagram"></script>
<script id="cookies_instagram_1" src="/sites/default/files/js/js_0ssbqVla228SIM5_T3Vbjqa8UQW-A3ZtkHW5AZXrCRo.js" type="text/plain" data-cookieconsent="instagram"></script>

When I navigate to js_0ssbqVla228SIM5_T3Vbjqa8UQW-A3ZtkHW5AZXrCRo.js, I see much more Javascript than just instagram.js has been knocked out.

Proposed resolution

When altering JS in the footer, prevent knocked-out scripts from participating in JS aggregation.

🐛 Bug report
Status

Fixed

Version

1.2

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024