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

17

u/occsceo Aug 21 '18

wait...wait...wait. how new is this? anyone have this running in a production app?

-14

u/esr360 Aug 21 '18

This has been around for ages. I've been using it in production for years. Read the docs sometimes guys lol, this is a standard documented API.

17

u/senocular Aug 21 '18

this is a standard documented API

Its in draft form currently: https://www.w3.org/TR/cssom-view-1/ So "standard" is a little bit of a stretch (in that its current form has not been formally standardized). The MDN page for MediaQueryList tags this as "This is an experimental technology" as well, so its understandable why this wouldn't necessarily be in widespread use.

2

u/XiMingpin91 Aug 21 '18

Explains why it isn’t more widely known