1// This is slow, it accesses the DOM element multiple times
2document.querySelector('#my-element').classList.add('my-class');
3document.querySelector('#my-element').textContent = 'hello';
4document.querySelector('#my-element').hidden = false;
5
6// This is faster, it stores the DOM element in a variable
7const myElement = document.querySelector('#my-element');
8myElement.classList.add('my-class');
9myElement.textContent = 'hello';
10myElement.hidden = false;