I'm trying to improve the load times on some sites by creating new JS files containing only the ATF code, using Puppeteer.
I've done this for CSS already but the same code doesnt work for JS as its deleting some parent wrappers but keeping the code inside so the format comes out all wrong.
Is there a specific flag I can use with Puppeteer or some additional checks I can add to the code in order to prevent this?
Any help is appreciated.
//map over array, check and add new text to var
js_coverage.map(e => {
if(e.url.includes('20210728')){
for(const range of e.ranges){
covered_js += e.text.slice(range.start, range.end) + "\n";
}
// console.log(e);
}
})
//write new text to new .js file
fs.writeFile("./exported_js.js", covered_js, function(err){
if(err){
return console.log(err);
}
console.log("JS Exported BOI!")
})