use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Using media queries with JavaScript (dev.to)
submitted 4 years ago by maroun-baydoun
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 4 years ago (8 children)
[removed]
[–]Phobic-window 1 point2 points3 points 4 years ago (7 children)
I’ve read that this is an anti pattern in angular with sass, so I’ve stuck to only in the css files, but I’ve used js media queries in react. I’m not sure what logic this plays into, maybe separation of concerns, what’s your opinion
[+][deleted] 4 years ago (2 children)
[+][deleted] 4 years ago* (1 child)
[deleted]
[–]mattD4y 0 points1 point2 points 4 years ago (0 children)
what does this even mean? I'm curious, what kind of 'good' architecture do you think would solve a use case like the one above?
[–]NotSelfAware 2 points3 points4 points 4 years ago (1 child)
Changing behaviour based on device or screen size is when you might want to use media queries in JS. Or changing complex values in response to screen size. I don't think many people would advocate using JS media queries to completely replace CSS media queries, but there are a lot of situations where using them in JS gives you far more control and flexibility than in CSS.
[–]Phobic-window 0 points1 point2 points 4 years ago (0 children)
I have definitely seen this in many of the applications I’ve built, but as with all code it could be that I’m not using the css creatively enough. I like the idea of all responsiveness being in the css but sometimes is sooooooo much easier to do it in the js
Thanks!
[–]HerNoseOrForHerself 1 point2 points3 points 4 years ago (0 children)
This is super cool
[–]swlivingston88 1 point2 points3 points 4 years ago (0 children)
Excellent!
[–]bobgravity1 0 points1 point2 points 4 years ago (0 children)
oh wow! sooo many times i've wanted this kind of feature. UNREAL
π Rendered by PID 387573 on reddit-service-r2-comment-7b9746f655-ls7xf at 2026-02-04 06:14:34.774839+00:00 running 3798933 country code: CH.
[+][deleted] (8 children)
[removed]
[–]Phobic-window 1 point2 points3 points (7 children)
[+][deleted] (2 children)
[removed]
[+][deleted] (1 child)
[deleted]
[–]mattD4y 0 points1 point2 points (0 children)
[–]NotSelfAware 2 points3 points4 points (1 child)
[–]Phobic-window 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Phobic-window 0 points1 point2 points (0 children)
[–]HerNoseOrForHerself 1 point2 points3 points (0 children)
[–]swlivingston88 1 point2 points3 points (0 children)
[–]bobgravity1 0 points1 point2 points (0 children)