Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-02-02 17:22:04

gilibaus
Member
From: Italy
Registered: 2013-08-14
Posts: 91
Website

Concatenating css files on-the-fly

Is there any Txp plugin that merges css files on-the-fly? Could not find any. Thanks.

Offline

#2 2018-02-02 17:49:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

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

#3 2018-02-02 21:56:09

gilibaus
Member
From: Italy
Registered: 2013-08-14
Posts: 91
Website

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

#4 2018-02-03 08:22:56

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

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

#5 2018-02-03 09:42:27

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

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

#6 2018-02-03 09:52:32

gilibaus
Member
From: Italy
Registered: 2013-08-14
Posts: 91
Website

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

#7 2018-02-03 11:02:33

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Concatenating css files on-the-fly

FWIW, concatenating multiple styles from the db looks possible:

<txp:css name="style1, style2" />

Offline

Board footer

Powered by FluxBB