Open stereobooster opened 6 years ago
this is not the best way to do this:
page.on("response", async response => {
....
} else {
await page.evaluate(route => {
const linkTag = document.createElement("link");
linkTag.setAttribute("rel", "preload");
linkTag.setAttribute("as", "image");
linkTag.setAttribute("href", route);
document.body.appendChild(linkTag);
}, route);
}
https://github.com/stereobooster/react-snap/issues/139
} else if (preconnectThirdParty) {
const urlObj = url.parse(responseUrl);
const domain = `${urlObj.protocol}//${urlObj.host}`;
if (uniqueResources.has(domain)) return;
await page.evaluate(route => {
const linkTag = document.createElement("link");
linkTag.setAttribute("rel", "preconnect");
linkTag.setAttribute("href", route);
document.head.appendChild(linkTag);
}, domain);
uniqueResources.add(domain);
}
Something like
minimalcss
doing. This, theoretically, should decrease memory usage.Use something else instead of
networkidle
, becausenetworkidle
waits 0,5 second after last network activity finished. Instead we can use page.waitFor. This, theoretically, should speed up things.See: https://github.com/peterbe/minimalcss/pull/118