Have a look at this Demonstration page (offline version is in the
This dependencie free and vanilla script is damn small: less than 1.3KB (uglyfied and GZipped)!
It's used in AB-interchange.
npm install --save ab-mediaquery
Import in your JS bundle (webpack, ES6, browserify...):
If you need a built version, it's in the
Init the script with:
Get current breakpointsABmediaQuerycurrent;// return an array of current breakpoints
Check specific breakpoint caseABmediaQuery;// return a boolean
changed.ab-mediaqueryevent is triggered when media query changes, you can listen to it:window;