Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS files that don't end with .css

Is there a disadvantage to using a dynamic Python file to generate the CSS for a webpage? I'd like computers with an administrator cookie to show special admin panel CSS, and show regular CSS for all other users. I'm planning to use:

<link rel="stylesheet" href="/css.py" type="text/css" />

2 Answers

That should work fine.

I hope, however, that you're not relying on CSS alone to restrict admin functionality.

like image 71
SLaks Avatar answered Feb 19 '26 21:02

SLaks


You can do that. Just realize that there will be a performance hit on each page. CSS files are usually cached as they do not change often.

In theory you do not need to even use an <link> as you can render the style right in the page as a <style>, as it will be refreshed every page request.

like image 40
Glennular Avatar answered Feb 19 '26 21:02

Glennular



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!