Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ClientLibraries] Add option to inject the onload attribute into the stylesheet link tag #2295

Closed
korben-ne-dallas opened this issue Sep 2, 2022 · 0 comments · Fixed by #2296 or #2692
Labels
Milestone

Comments

@korben-ne-dallas
Copy link
Contributor

Feature Request

Currently Sling Model that used to collect and include client libraries allows to add the onload attribute only to the javascript script tag. It would be useful to be able to add this attribute to the stylesheet link tag as well.

In my personal case I'm going to use this attribute to implement loading of non-critical css in a non-blocking way, but I think this attribute can also be useful in some other cases.

Solution
Add the onload attribute for css here: com.adobe.cq.wcm.core.components.internal.models.v1.ClientLibrariesImpl.

Example of usage
<sly data-sly-use.clientlibs="${'com.adobe.cq.wcm.core.components.models.ClientLibraries' @ categories='wknd.base',       media='print' onloadCss='this.media=\'all\''}">
          ${clientlibs.cssIncludes @ context="unsafe"}
</sly>

Result
<link rel="stylesheet" href="style.css" media="print" onload="this.media='all'">

vladbailescu pushed a commit that referenced this issue Mar 2, 2024
…stylesheet link tag (#2296)

* [ClientLibraries] Add option to inject the onload attribute into the stylesheet link tag
* [ClientLibraries] Inject existing onload attribute into the stylesheet link tag
Fixes #2295
@vladbailescu vladbailescu added this to the 2.24.4 milestone Mar 2, 2024
vladbailescu pushed a commit that referenced this issue Mar 4, 2024
…stylesheet link tag (#2296)

* [ClientLibraries] Add option to inject the onload attribute into the stylesheet link tag
* [ClientLibraries] Inject existing onload attribute into the stylesheet link tag
Fixes #2295
@vladbailescu vladbailescu modified the milestones: 2.24.4, 2.24.6 Mar 29, 2024
@LSantha LSantha added the done label Apr 29, 2024
LSantha added a commit that referenced this issue Apr 30, 2024
…nto the stylesheet link tag (#2692)

* Add option to inject the onload attribute into the stylesheet link tag
* Inject existing onload attribute into the stylesheet link tag
* fixed ITs

---------

Co-authored-by: korben-ne-dallas <alexvedenov@gmail.com>
Co-authored-by: Levente Sántha <levente@adobe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment