Post Reply: Css Style
2024-8-15 08:0:0 Author: fyr.io(查看原文) 阅读量:2 收藏

Post Reply: CSS Style

Posted on

FlamedFury.com asks: What do you name your CSS stylesheet in small web projects? This post is a reply to that post.


Historically, I've always used style.css, kept inside the /css directory (as you can see on this site too!) but I've been wondering more recently whether this is a good idea?

I consider this site a small, but growing, project. I added theme support a while ago and made the decision to keep the themes in the same, single stylesheet instead of splitting out each theme into different files. This, in my mind, makes for less loading of resources. At least overhead-wise anyway. However, I'm only two CSS themes in and already I'm reconsidering.

I can imagine adding ten, fifteen themes here, and sure, switching between them would be super fast via a Javascript-powered class change on the <body> as the client doesn't need to transfer any data; the relevent stuff is already in the cache'd CSS file... but a whole bunch of people won't bother to switch themes and that is a decent percentage of transferred data wasted. Plus, having everything crammed into one file makes editing things somewhat unwieldy on my end.

So I'm considering breaking things up, perhaps a core structure file, followed by theme files which load in and out depending on the selected theme, each, of course, named after the theme they represent.

I'll probably still name that core file style.css though :D

Until then, I guess my style.css should technically be called styles.css as it has multiple styles in it... hrm.


文章来源: https://fyr.io/post/post_reply:_css_style
如有侵权请联系:admin#unsafe.sh