I have javascript that has a window event listener that loads a function. I would like to disable this event listener on mobile though. How can I achieve this?
window.addEventListener("load", setupMathCalculator);
I have javascript that has a window event listener that loads a function. I would like to disable this event listener on mobile though. How can I achieve this?
window.addEventListener("load", setupMathCalculator);
You can use window.matchMedia, just pass an argument with proper media query:
const media = window.matchMedia("(max-width: 700px)")
if (media.matches){
window.addEventListener("load", setupMathCalculator);
}