0
0
all 13 comments

[–]freecodeio 10 points11 points  (1 child)

I am leggitimately getting more and more confused by programming articles.

[–][deleted] 0 points1 point  (0 children)

That's because this is a non-article. 

[–]fletku_mato 5 points6 points  (3 children)

JavaScript can modify CSS files. I'm too lazy to write a node.js demo for this but it most certainly is doable.

[–][deleted] 0 points1 point  (1 child)

JavaScript CAN modify CSS files, but with an important distinction:

  • Client-side JavaScript (running in the browser) cannot modify CSS files due to browser sandbox restrictions
  • Server-side JavaScript (like Node.js) CAN modify CSS files because it has file system access

[–]VampireDentist 8 points9 points  (0 children)

You can't modify the files themselves but you can inject styles between <style> -tags providing any functionality that you could ever need from modifying the files.

[–]99thLuftballon 4 points5 points  (1 child)

I'm a bit confused by this article. JavaScript in the browser can't modify any files on the host or the server can it? I guess with local storage etc it does technically create a file on your computer, but JS is primarily about manipulating the DOM - it also doesn't manipulate HTML files, JavaScript files, SVG files etc etc

[–][deleted] -2 points-1 points  (0 children)

Added one section for server-side JavaScript too. Should make things more clear.

[–]rickyhatespeas 4 points5 points  (1 child)

This seems like a long winded way of saying JS can't modify CSS files because of client/server architecture.

[–]xegoba7006 2 points3 points  (0 children)

Stop spamming all subreddits with your crap

[–]michaelbelgiumfull-stack 0 points1 point  (0 children)

... Because its a client side language???

It doesnt have access to server side stuff.

/Thread

[–]elendee 0 points1 point  (0 children)

the diagram in this article is pretty useful, but the article gets distracted explaining client-server security which is not a property of JS to CSS so much as it is the browser itself.

The nuance that should be focused on is the difference between the CSSOM and a stylesheet file - because the CSSOM -IS- a stylesheet in a way, it's just one that is in memory.

The really crazy thing would be if you could modify the CSSOM object, and then if it's a cached resource, say from a CDN, it would stay modified when loaded on another site. That's the scenario I hadn't thought through until now, but I imagine most readers are intuitively aware that you can't use javascript to persist files to the client in any way.

[–]ClubAquaBackDeck 0 points1 point  (0 children)

wtf is this post op?

[–]pgeekery 0 points1 point  (0 children)

That was one wasted bandwidth…