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
-3
u/amejin Aug 22 '18 edited Aug 22 '18
Im not sure your script should behave differently than intended just because the window size changes.
As I learned it, layout, in majority, should be handled by css. Script is for data and state, and fringe cases where css cant meet the need or is not optimal or performant.
Maybe its my limited vision, but Im not sure this would be the thing I run to when thinking about how a page will look and feel on different devices. A menu button should continue to display a menu. The menu layout and design can be controlled with media queries already and the script should have nothing to do with it (in my very humble opinion).
Now - we all know in programming there are always multiple avenues to solve a problem. If this solves yours, feel free to use it. :)
Edit: punctuation, a word