Problem: "Is there a nice pattern for using Critical via Gulp for CSS across a site with many pages which might be subtly different?"
The way I've tackled this in the past is breaking down the pages that might be slightly different into groups which each have their
own Gulp task. For the sake of simplicity, we could have a set of pages that fall under red-theme
, blue-theme
etc. For each group,
run critical.generate()
against the set of URLs for the group (so, red-theme
URLs) and allow it to inline the CSS for just that group.
The benefit of thinking about this problem in a group for each task is if you need to apply additional customisations, config or build-time
fixes per variation of page/theme, it's pretty trivial to do so. You then just run all of the critical group tasks near the end of your
build and this should work.
Thanks for this. Makes sense.
So you have Gulp tasks to pipe a group of html files into the critical.generate() task, or is there a nice way to use a glob as the source to inspect?