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

Latest commit

 

History

History
27 lines (14 loc) · 533 Bytes

no-call-dom-object-multiple-times.md

File metadata and controls

27 lines (14 loc) · 533 Bytes

Assign to variable DOM objects access multiple times (s32)

Rule Details

This rule aims to reduce DOM access assigning its object to variable when access multiple time. It saves CPU cycles.

Examples of incorrect code for this rule:

var el1 = document.getElementById('block1').test1;
var el2 = document.getElementById('block1').test2;

Examples of correct code for this rule:

var blockElement = document.getElementById('block1');
var el1 = blockElement.test1;
var el2 = blockElement.test2;