0

Which one is faster render to dom using quarySelector or getElementById

ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById('root') ); Or ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.quarySelector('.root') );

7th Dec 2021, 9:54 AM
EsaKurniawan
4 ответов
0
https://beamtic.com/getelementbyid-vs-queryselector Some other article will say query is faster. It look like not big diference in performance between this two when selecting id. Also when you create react app default is ById, and most people dont change this at all.
7th Dec 2021, 10:14 AM
PanicS
PanicS - avatar
0
PanicS thanks for answer my question, if quary little bit faster i will change byId to quary then
7th Dec 2021, 10:18 AM
EsaKurniawan
0
Some say id is faster, some say query. Maybe is diference between task given, browser, pc setup... But diference is not big, use one you think is better. Also you can look on internet to learn how to check performance, so you can check your app and deside what to use.
7th Dec 2021, 11:37 AM
PanicS
PanicS - avatar
0
Ok, thanks for helping me
7th Dec 2021, 12:10 PM
EsaKurniawan