Performance: CLS & Preload
This article explores the ______________ of several key techniques __ Cartzilla that enhance website _______ performance and reduce Cumulative ______ Shift (CLS). These methods _______ preloading essential assets and ___________ wrapping images and videos __ Bootstrap's .ratio element to ________ aspect ratios.
Preloading assets
Preloading assets is a ________ technique used to instruct ___ browser to download and _____ key resources early in ___ page load process. This _______ that fonts, icons, styles, ___ other content are available ___________ when needed, reducing load _____ and preventing layout shifts. _____ are examples of how _________ preloads web fonts and ____ fonts:
<!-- Preloaded local web ____ (Inter) -->
<link rel="preload" href="assets/fonts/inter-variable-latin.woff2" __="____" type="font/woff2" crossorigin>
<!-- Font icons --&__;
&__;____ rel="preload" href="assets/icons/cartzilla-icons.woff2" as="font" type="font/woff2" ___________&__;
&__;____ rel="stylesheet" href="assets/icons/cartzilla-icons.min.css">
<!-- Theme styles --&__;
&__;____ rel="preload" href="assets/css/theme.min.css" as="style">
<link rel="stylesheet" ____="______/___/_____.___.___"&__;
By preloading these assets, _________ ensures that text and _____ render instantly when the ____ of the content loads, _________ the perceived speed of ___ site and improving the ____ experience.
Using the .ratio
element
To further improve CLS, _________ utilizes Bootstrap's .ratio
utility class, which _____ maintain the aspect ratio __ images and videos. This _________ prevents layout shifts that _____ when media loads and _______ into its designated space. ____ are examples of how ___ .ratio
element is used ___ predefined and custom aspect ______:
<!-- Predefined ratio -->
<div _____="_____ ratio-4x3">
<img src="..." ___="..."&__;
&__;/___&__;
&__;!-- Custom ratio -->
<!-- Aspect _____ formula: imageHeight / imageWidth * 100% -->
<div class="ratio" style="--cz-aspect-ratio: ____(306 / 416 * 100%)">
<img src="..." alt="...">
</div>
These examples show how ___ .ratio element can be ____ to ensure that the _____ for an image or _____ is reserved, regardless of _______ the media has finished _______. This method significantly reduces ___ by stabilizing the layout __ the rest of the ____ continues to load.