Critical Path CSS Generator
Penthouse is a tool generating critical path CSS for your web pages and web apps in order to speed up page rendering. Supply the tool with your site's full CSS, and the page you want to create the critical CSS for, and it will return all the CSS needed to render the above the fold content of the page. Read more about critical path css here.
The process is automatic and the generated CSS is production ready as is. If you run into problems however, check out the Problems section further down on this page.
Penthouse can be used:
npm install --save-dev penthouse
This will add penthouse to the list of dependencies.
Require as normal and execute with a callback:
var penthouse =path =fs =__basedir = './';;
The Penthouse Node module can also be used in Gulp.
Before going further, make sure that you fix any errors in CSS as detected by this CSS parser, as they can cause problems with critical CSS generation.
Change any relative paths (f.e.
background-image: url("../images/x.gif");) to absolute (starting with a
background-image: url("/images/x.gif");, and then try again.
If you for some reason have an element appearing early in the DOM, but that you apply styles to move outside of the above the fold content (using absolute position or transforms), consider whether it really should appear so early in the DOM.
Problems with special characters like → after converting? Make sure you use the correct hexadecimal format in your CSS. You can always get this format from your browser console, by entering '→'
.charCodeAt(0).toString(16) (answer for this arrow glyph is
2192). When using hexadecimal format in CSS it needs to be prepended with a backslash, like so:
Please report your issue (check that it's not already there first though!), and I will try to fix it as soon as possible.