r/javascript • • Aug 21 '18

Effectively supported in all browsers, JavaScript has its own form of media queries just like CSS.

https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
465 Upvotes

114 comments sorted by

View all comments

32

u/MayorMonty Aug 21 '18 edited Aug 22 '18

Huh, TIL. And to think I've been using resize events for all these years now...

Edit: scroll events are different

2

u/lackbotone Aug 22 '18

How are scroll events related to this? Just curious, I genuinely don't understand.

3

u/MayorMonty Aug 22 '18

Oh shoot, I meant to say resize events. I need to proofread more ;-)

20

u/GottfriedEulerNewton Aug 22 '18

Nah, just catch it at runtime