Wedge

Public area => The Pub => Plugins => Topic started by: Nao on January 25th, 2013, 03:39 PM

Title: Plugin CSS in regular files?
Post by: Nao 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
Title: Re: Plugin CSS in regular files?
Post by: Arantor 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?
Title: Re: Plugin CSS in regular files?
Post by: Nao 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...
Title: Re: Plugin CSS in regular files?
Post by: Arantor 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.
Title: Re: Plugin CSS in regular files?
Post by: live627 on January 26th, 2013, 12:42 AM
http://wedge.org/pub/plugins/6985/plugin-css-added-to-the-main-list/

I still use this method...
Title: Re: Plugin CSS in regular files?
Post by: Nao on January 27th, 2013, 11:14 AM
Wasn't this seen as too hackish..?
I guess only time will tell...!
Title: Re: Plugin CSS in regular files?
Post by: live627 on January 27th, 2013, 06:02 PM
II see it as saving on HTTP requests, which is always a good thing.
Title: Re: Plugin CSS in regular files?
Post by: Arantor 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.