Plugin CSS in regular files?

Nao

  • Dadman with a boy
  • Posts: 16,082
Plugin CSS in regular files?
« on January 25th, 2013, 03:39 PM »
I was thinking of something...
Perhaps it's already implemented that way, but I doubt it.

How about having a function (or extend add_plugin_css_file or something to do it), that takes a request from a plugin to 'add some CSS to this or that general file'.
- It the file doesn't exist, just create it...
- If it does exist, then add somewhere in a variable that next time we flush the file (say, index.css), we'll need to get some extra CSS from that list of plugins, and add it to the end of our file. Or something.

That would save having to use an extra HTTP request or inline CSS for some minor feature we want on every page.

Then again -- maybe it's already all implemented... Maybe it's not even doable. But Pete asked me to open new topics for every little idea or suggestion I have, so there I am... :P

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Plugin CSS in regular files?
« Reply #1, on January 25th, 2013, 05:04 PM »
What happens when the plugin is disabled? Are you planning to add the name of the plugin to the name of built CSS file?
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Plugin CSS in regular files?
« Reply #2, on January 25th, 2013, 07:01 PM »
Hmmm... Makes sense to ask these ;)
I don't think I would accept the drawbacks over the advantages, I guess...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Plugin CSS in regular files?
« Reply #3, on January 25th, 2013, 08:32 PM »
The latter question is particularly important, because it's the one reason I specifically wrote add_plugin_css_file to not join all the plugin CSS files together on a single page load, because as far as I was concerned, if you did that you could have an exponential number of CSS files.

The former is also important because plugins don't necessarily advise other systems when they are disabled for any reason, and they're not going to force a cache rebuild either.

There are, as I see it, two distinct kinds of CSS that a plugin needs to add - CSS for its own stuff when it's in use, which will typically be its own file but otherwise static (e.g. the calendar has a CSS file, the helpdesk has a couple too), while I can also imagine adding inline CSS for the specific occasions where an entire file is not needed, or when it is dynamically computed for whatever reason.

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Nao

  • Dadman with a boy
  • Posts: 16,082

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Plugin CSS in regular files?
« Reply #7, on January 27th, 2013, 06:09 PM »
There's saving on HTTP requests as the expense of dramatically increasing server space usage. No need to introduce CSS files to the master files if they're only occasionally used.

What we could always do is introduce a parameter to add_plugin_css_file to indicate whether to force it into main running order or not, default to not.