Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.83 KB

BP_4017_en.md

File metadata and controls

45 lines (29 loc) · 1.83 KB

Only load data/code when necessary

Identifiers

GreenIT V2 V3 V4

Categories

Life cycle Tiers Responsible
3. Implementation User/Terminal Software Architect/Developer

Indications

Priority Implementation difficulty Ecological impact
4 3 5
Saved resources
Queries

Description

It may be tempting to pre-load resources that could be used when specific actions are performed by users (including navigating to another page) for perceived performance reasons.

These preloads will only result in wasted resources when these actions aren't taken.

Example

Avoid <link rel="prerender">, as well as all rel="preload", rel="prefetch", rel="preconnect", rel="modulepreload" and rel="dns-prefetch" on resources that will not be used on the current page, or used only under certain conditions.

Avoid loading and caching (or storing locally) application data, such as values lists and other references if there is no guarantee that they will be used.

By extension, divide JS code, and even CSS, into portions (chunks) related to specific user actions, and only load those portions when necessary. This is especially true for SPAs (Single Page Applications), where each screen (or possibly set of screens) can only be loaded on demand.

Validation rule

The number of ... is equal to or less than
loaded resources that are not immediately used 0