Home › Forums › JavaScript › How to remove script for responsive media queries? › Reply To: How to remove script for responsive media queries?
December 19, 2017 at 1:48 pm
#264064
PicnicTutorials
Participant
Thanks guys. So I found a solution.
Using jquery then say…
if ( $(window).width() > 739) {
//Add your javascript for large screens here
}
else {
//Add your javascript for small screens here
}
Question though. Does the above do the exact same thing as the code below? Or is one better
if (window.matchMedia(“(min-width: 400px)”).matches) {
/* the viewport is at least 400 pixels wide /
} else {
/ the viewport is less than 400 pixels wide */
}