Last active
November 15, 2020 01:56
-
-
Save daviddarke/711eaf6cb4fffa5968cdf6c5ff810a93 to your computer and use it in GitHub Desktop.
Revisions
-
daviddarke revised this gist
May 1, 2019 . 1 changed file with 12 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,15 @@ // Check that required variables exist if( ( process.argv[2] == undefined ) || ( process.argv[3] == undefined ) ){ console.log('Missing variables') console.log('1, local path to coverage file. 2, url to target css file') return; } (async () => { var fs = require("fs"); // Get content from file var contents = fs.readFileSync( process.argv[2] ); // Define to JSON type var jsonContent = JSON.parse(contents); @@ -13,23 +18,19 @@ var fs = require('fs'); for (i = 0; i < jsonContent.length; i++) { // console.log( jsonContent[i] ); if( jsonContent[i].url == process.argv[3] ){ console.log( 'Critical CSS from: ' + process.argv[3] ); for (j = 0; j < jsonContent[i].ranges.length; j++) { slices.push( jsonContent[i].text.slice( jsonContent[i].ranges[j].start, jsonContent[i].ranges[j].end )); } } } console.log('------------------------------------------------') console.log(slices.join('')); console.log('------------------------------------------------') })(); -
daviddarke renamed this gist
May 1, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
daviddarke created this gist
Apr 28, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ var fs = require('fs'); (async () => { var fs = require("fs"); // Get content from file var contents = fs.readFileSync("Coverage.json"); // Define to JSON type var jsonContent = JSON.parse(contents); const slices = []; for (i = 0; i < jsonContent.length; i++) { // console.log( jsonContent[i] ); for (j = 0; j < jsonContent[i].ranges.length; j++) { // console.log( 'start' ); // console.log( jsonContent[i].ranges[j].start ); // console.log( 'end' ); // console.log( jsonContent[i].ranges[j].end ); if( jsonContent[i].url == 'https://atomicsmash-725c.kxcdn.com/wp-content/themes/atomicsmash5/assets/css/screen.css?ver=190222-114139' ){ slices.push( jsonContent[i].text.slice( jsonContent[i].ranges[j].start, jsonContent[i].ranges[j].end )); } } // jsonContent[i].text; } console.log(slices.join('')); })();