Give the page a second or so to enhance before running criticalCSS
scottjehl opened this issue · comments
Scott Jehl commented
I noticed that criticalCSS often runs before JS fully applies to a page, and that can mean certain selectors won't apply, among other things. Adding a short delay after page load seems to work around this issue, at least for the filamentgroup.com site.
I currently have this in the task runner and it's working:
function runit(){
var crit = cc.criticalCSS( filename, opts );
if( crit.length === 0 ){
throw new Error( "criticalCSS didn't run or no critical css, that seems unlikely" );
} else {
system.stdout.write(crit);
phantom.exit();
}
}
// give the JS a second to run
setTimeout( runit, 1000 );
cc @jefflembeck
Scott Jehl commented
Never mind. This doesn't seem to fix it. Still looking...
Scott Jehl commented
I think I'm seeing a different issue entirely - closing for now