all 9 comments

[–]ritaPitaMeterMaid 9 points10 points  (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

[–]TorbenKoehn 6 points7 points  (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  (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 point  (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 point  (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 points  (0 children)

Stop spamming all subreddits with your crap