Feature: #99510 - Add file embedding option to asset ViewHelpers
See forge#99510
Description
The ViewHelpers <f:asset.css>
and <f:asset.script> have
been extended with a new argument
inline
. If this argument is set,
the referenced asset file is rendered inline.
Setting the argument will therefore load the file content of the defined
href
/
src
as inline style or script. This is especially
useful for content elements which are used as first element on a page and
need some custom CSS to improve the Cumulative Layout Shift (CLS).
Impact
To add inline styles and scripts from a referenced file, the new
inline
argument can be set. For example, to add above-the-fold styles, the
priority
option can be set, which will put the file contents of
EXT:
as inline styles
to the
<head>
section.
<f:asset.css identifier="my-hero" href="EXT:sitepackage/Resources/Public/Css/my-hero.css" inline="1" priority="1"/>
To add JavaScript:
<f:asset.script identifier="my-hero" src="EXT:sitepackage/Resources/Public/Js/my-hero.js" inline="1" priority="1"/>