Only run some javascript when the browser is 767px or smaller.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function responsiveScript() { | |
// only run script below 767 px screen width | |
if (window.innerWidth <= 767) { | |
// do something awesome on mobile only here | |
} | |
} | |
// run script on page load | |
responsiveScript(); | |
// run script on window resize | |
window.addEventListener("resize", responsiveScript); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment