libraryOverrides load same js-files twice

Created on 15 August 2023, over 1 year ago

Problem/Motivation

When using SDCs, I've noticed that the same JS files from two different components get loaded twice on page load. This behavior contrasts with attach_library() which intelligently ensures that JS files are attached only once.

Steps to reproduce

1. Use SDCs "libraryOverrides" to attach a JS file to a component.
2. Attach the same JS file to another component
3. Include both components on one page
4. Observe that the JS file is loaded twice in Inspector.

Expected result
The JS file should be loaded only once, similar to the behavior of attach_library().
Actual Result:

The JS file is loaded twice on the page, leading to redundancy and potential performance issues.

Additional Information
I understand that attach_library() has its mechanism to prevent redundant loading, and it would be great if SingleDirectoryComponents could adopt a similar strategy. Redundant file inclusion can lead to performance issues, especially if the file size is large, or if there are many redundant inclusions.

Suggested Resolution
Please investigate the logic behind SingleDirectoryComponents and consider enhancing it to ensure JS files (or any assets) are loaded only once on a page, irrespective of how many times they are attached.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇦🇹Austria roromedia Linz

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024