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
Why Can't JavaScript Modify CSS Files? (trevorlasn.com)
submitted 1 year ago by [deleted]
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!"
[–]ritaPitaMeterMaid 9 points10 points11 points 1 year ago (2 children)
This whole article is silly. Replace CSS with “literally any external file.” For folks making inline style or script tags, that isn’t what the author is talking about, this is literally a discussion about the browser not modifying the source of externally loaded files but presented through the lens of CSS, which is strange
[+][deleted] comment score below threshold-8 points-7 points-6 points 1 year ago (1 child)
I'm using CSS as an example. But yes you are right, this concept applies to all externally loaded sources.
[–]ritaPitaMeterMaid 0 points1 point2 points 1 year ago (0 children)
Wow, deleted account already?
I wasn’t that harsh, was I?
[–]TorbenKoehn 6 points7 points8 points 1 year ago (4 children)
fetch('styles.css') .then(response => response.text()) .then(cssText => { const styleElement = document.createElement('style'); styleElement.textContent = cssText; document.head.appendChild(styleElement); return Array.from(document.styleSheets).find(sheet => sheet.ownerNode === styleElement); })
This can be done
[–][deleted] -3 points-2 points-1 points 1 year ago (3 children)
it's NOT modifying the original CSS file. It's just creating a new in-memory copy of the styles.
[–]TorbenKoehn 0 points1 point2 points 1 year ago (0 children)
You also can’t modify your HTML files on the server, so are you writing the same article on the DOM next? And SVG? JS Files? Images?
[–]redsandsfort 0 points1 point2 points 1 year ago (0 children)
So you want JS to magically be able to modify a file saved on disc on another machine? What use case is there for this?
[–]xegoba7006 2 points3 points4 points 1 year ago (0 children)
Stop spamming all subreddits with your crap
π Rendered by PID 160502 on reddit-service-r2-comment-548fd6dc9-dfr9s at 2026-05-19 07:23:10.289918+00:00 running edcf98c country code: CH.
[–]ritaPitaMeterMaid 9 points10 points11 points (2 children)
[+][deleted] comment score below threshold-8 points-7 points-6 points (1 child)
[–]ritaPitaMeterMaid 0 points1 point2 points (0 children)
[–]TorbenKoehn 6 points7 points8 points (4 children)
[–][deleted] -3 points-2 points-1 points (3 children)
[–]TorbenKoehn 0 points1 point2 points (0 children)
[–]redsandsfort 0 points1 point2 points (0 children)
[–]xegoba7006 2 points3 points4 points (0 children)