I'm trying to improve my code performance. There's a line of code that takes more time than all of the other code combined. Take a look at the highlighted function below
It takes 125ms to read the offsetHeight. Here's the code that the performance tab highlights
const navBar = document.querySelector('.navigation.fixed');
if(navBar){
const navBarHeight = navBar.offsetHeight,
isRetracting = navBar.classList.contains('retracting');
let scrollPos = window.scrollY;
...
I don't see what's so difficult about this that the browser is spending such a long time to read this height. Can someone explain to me what could be the reason for it?