We are trying to minimize Forced Reflows which can be caused by stuff like getComputedStyle()
.
Our problem: Currently we are passing our CSS breakpoints to JavaScript by having an DOM element with the following styling:
.breakpoint {
display: none;
@media (min-width: $breakpoint-medium) {
display: block;
}
@media (min-width: $breakpoint-large) {
display: flex;
}
}
Then in JS we check the display
property with getComputedStyle()
which causes a Forced Reflow.
Do you have an other way of passing the CSS breakpoints to JS without having the Forced Reflow?
Thank you!