UNPKG

atf

Version:

atf (above-the-fold) prints out above-the-fold css for whatever site you want.

26 lines (21 loc) 687 B
'use strict'; var phantom = require('phantom'); module.exports = function (url) { phantom.create(function(ph) { return ph.createPage(function(page) { return page.open(url, function(status) { console.log("opened site? ", status); page.injectJs(__dirname + '/criticalCss.js', function() { setTimeout(function() { return page.evaluate(function() { return printAboveTheFoldCss(); }, function(result) { console.log(result); ph.exit(); }); }, 5000); }); }); }); }); };