I don't care about caching or performance - for some reason I shouldn't use inline CSS?

As part of my work, I support / develop an internal web application. This one has relatively few users and just not that many. I have a global CSS file that contains some reusable styles, but 90% of my page-specific styles really do relate to the page; they are like pseudo-column widths (most of my output is simply not a table to make tables a poor choice). I undertook to just throw a <style> block at the top of these pages.

I know this is disapproving, but every time I read about the reasons for individual CSS files, the only thing that really stands out is caching. In this case, it does not matter; this is a LIST in the list of things I would do if I needed to speed up the application. Are there any other reasons, or can I stop feeling guilty?

+4
source share
4 answers

every time I read about the reasons for individual CSS files, the only thing that really stands out is caching

Really?

Every time I read about their use, the fact that you can change something in the CSS file and all the pages that include it will have a change is the most important reason for using them.

Having your centralized centralized service is a good thing, even if your specific pages have different specific rules. This helps you to unify the basic CSS structure on the site and when searching for how a particular effect was achieved, it will be easy to find.

All this is a good reason to use CSS files, far exceeding any reasons for caching / performance.

+7
source

I am facing a similar problem as most of my styles are very page specific. However, my site is far from small, so I had to find a solution.

As a result, I created the css/pages folder and named each CSS file the same as the page that uses it. Then my PHP template can simply check if(file_exists("css/pages/".basename($_SERVER['PHP_SELF']))) and add the appropriate <link/> , which will result in minimal effort on my part.

Just because your site is small is not a good reason to ignore performance, although I have to say that I am a little useful, so I will probably be more pedantic: p

Ultimately, there is nothing "wrong" with simply placing the CSS page directly on the page, just make sure that everything that is used on more than one page is in the file, so you don’t need to repeat yourself.

+2
source

In my opinion, if your application contains only a few web pages (3-5 pages), then you can define it at the top of the web pages. If your application grows to more than 3-5 web pages, then global CSS will help with maintainability and scalability.

+1
source

Makes a cleaner premium, faster downloads. Really refers to the pattern and dynamic development. Do not be afraid to use it. This is not like going to the dark side.

0
source

All Articles