Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Minimize DOM access - JavaScript

// This is slow, it accesses the DOM element multiple times
document.querySelector('#my-element').classList.add('my-class');
document.querySelector('#my-element').textContent = 'hello';
document.querySelector('#my-element').hidden = false;

// This is faster, it stores the DOM element in a variable
const myElement = document.querySelector('#my-element');
myElement.classList.add('my-class');
myElement.textContent = 'hello';
myElement.hidden = false;
Comment

PREVIOUS NEXT
Code Example
Javascript :: jsdelivr discord 
Javascript :: javascript got array object by id 
Javascript :: React native-base DatePicker comes up Minimized on iOS Asked 
Javascript :: jquery to animate a flash to the button selected 
Javascript :: __filename not defined in mjs files 
Javascript :: 1541847516 
Javascript :: what does concurrently package do 
Javascript :: symbols with object.assign 
Javascript :: input file selector on button click vuejs 
Javascript :: Utils is not a constructor MuiPickersUtilsProvider 
Javascript :: how to push an object into an array in reducer 
Javascript :: save in local storage with expiration 
Javascript :: bad request while authenticating locally with passport-local-mongoose stackoverflow 
Javascript :: react userefrence example 
Javascript :: handlebars.registerHelper is not a function 
Javascript :: angular taskkill in port 4200 
Javascript :: 8.1.3. Varying Data Types¶ Arrays 
Javascript :: if statement inside a function in javascript 
Javascript :: strict scalar types 
Javascript :: react-image-lightbox npm 
Javascript :: %20find%20all%20docs%20that%20have%20at%20least%20two%20name%20array%20elements_ 
Javascript :: react native getting older version assets 
Javascript :: arrow function no need for parentheses with only one parameter 
Javascript :: allow cookies sent by the client 
Javascript :: scroll to a input on button click react native 
Javascript :: react get dynamic window sizes 
Javascript :: html how to get js 
Javascript :: addingbackground image in nodejs 
Javascript :: petShopIndex.html:137 Uncaught ReferenceError: $ is not defined jquery node 
Javascript :: start withnreact 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =