matchMedia which will listen for a specific value and trigger when true. For example:
var mediaQuery = window.matchMedia('(min-width: 768px)');
When we add a listener to the variable it can run a function:
This opens the possibility of passing any function to the listener and only having that function run on certain screen widths.
matchMedia function is widely supported, including full support for Internet Explorer 10 and 11.
Today’s Tuesday Tips was adapted from a post on Daily Dev Tips.