defer
,
async
, and/or
onload
attributes on your
script
elements. Likewise, while managing your cross-origin resource sharing (CORS) HTTP requests, you may want to utilize the
crossorigin
attribute on your
script
and/or
link
elements for JavaScript and CSS.
clientlib.html
contains named Sightly template blocks (
js
,
css
,
all
), which in turn set the proper Sightly expression option for mode and call the named Sightly templates in
graniteClientLib.html
.
graniteClientLib.html
then sets the proper Sightly expression options and delegates the more complex logic to a Java-Use API POJO.
ClientLibUseObject.java
then utilizes the
HtmlLibraryManager
in order to write out the final HTML markup.
/libs/granite/sightly/templates
node. To make any alterations, we simply copy all three files out of
/libs
into
/apps
, update the files, and update our Sightly components to point to the new clientlib component (usually
headlibs.html
or similar partial in the page component).
loading
,
onload
, and
crossorigin
options.
HtmlLibraryManager
's
writeIncludes
,
writeCssInclude
and
writeJsInclude
methods. However, since we want custom markup, we need to do that ourselves in the POJO.
I don't think dependencies are added like this. Changing the last "false" on line 197 of ClientLibUseObject.java to "true" seems to load dependencies.
Thanks for sharing the implementation. It is really helping us. We are now planning to use ACS commons versioned clientlibs however it seems rewrite is not happening like clientlibs.ACSHASHa4a8665a4aa416b3044a3155a22a2e06.css" Do you have any suggestion to make it work with versioned clientlibs ?
VersionedClientLib checks if the 'type="text/javascript" ' attribute is present. Just add it to your js_tag string constant and the VersionedClientLib should append md5 checksums
or 'type="text/css"' respectively
Where does the ClientLibUseObject.java class get compiled in AEM and how can I force it to recompile? I've made changes to it, but it doesn't appear to reflect.
Nono Junang | June 06, 2016 at 07:58 AM | Reply
Nice, Let's say I load a client lib with the option async or defer, do all its dependencies also get loaded with the same options (async or defer)? Cheers, Nono