Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Concatenating css files on-the-fly
Is there any Txp plugin that merges css files on-the-fly? Could not find any. Thanks.
Offline
Re: Concatenating css files on-the-fly
Not that I’m aware of. There is a callback css.url
that’ll pass you the name
parameter of the <txp:css
> tag, so if you’re a dab hand with PHP you should be able to grab that and intercept it, handling that parameter as a list instead of a single item.
Might be a nice feature if we did this in core, but our CSS handler is a bit limited right now. Maybe one day.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Concatenating css files on-the-fly
Unfortunately no expert at PHP :(
But found this easy and working solution: https://github.com/mrclay/minify
Offline
Re: Concatenating css files on-the-fly
Personally, I’m strongly in favour of keeping the css out of your Textpattern control panel and simply use a flat file for it. Link it into your Textpattern page templates using standard html.
But obviously still concatenate to a single css file and minify. CSSnano is better than minify at creating smaller files.
Offline
Re: Concatenating css files on-the-fly
I concatenate and minify it outside Textpattern.
The integration goes like this, so Google PageSpeed Insights is satisfied ;-):
<style><txp:php>echo(file_get_contents('css/min/complete.css'));</txp:php></style>
Offline
Re: Concatenating css files on-the-fly
@philwareham totally agree, actually I link my css flat files into my Textpattern page templates using standard html. Thanks for CSSnano suggestion, I will give it a look.
Offline
Re: Concatenating css files on-the-fly
FWIW, concatenating multiple styles from the db looks possible:
<txp:css name="style1, style2" />
Offline