Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Latest commit

 

History

History
30 lines (17 loc) · 596 Bytes

no-direct-DOM-access.md

File metadata and controls

30 lines (17 loc) · 596 Bytes

No DOM access without assignation (s57)

Rule Details

This rule aims to limit DOM access

DOM access cost a lot of resources. We should be using variables to avoid requesting the same element multiple times If you are doing a single reference, you can ignore this suggestion

Examples of incorrect code for this rule:

document.getElementById("myElement").action1();
document.getElementById("myElement").action2();

Examples of correct code for this rule:

const myElement = document.getElementById("myElement");
myElement.action1();
myElement.action2();