r/javascript • u/[deleted] • 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
r/javascript • u/[deleted] • Aug 21 '18
-2
u/[deleted] Aug 22 '18 edited Aug 22 '18
Can anyone answer why this would be better than using window.innerWidth?
Because I've been using window.innerWidth to check if I should render a mobile version of React component and it did its job without problem (that I know of).
Edit: I don't know what the problem is of these people downvoting me? I'm asking a normal question. Your downvotes are just rude.