Для jQuery:
function myFunction() {
var width = $(window).width();
if (width < 767) {
alert('less than 767px');
}
}
$(window).resize(myFunction);
myFunction();
VanillaJS:
function myFunction() {
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 767) {
alert('less than 767px');
}
}
window.onresize = myFunction;
myFunction();