Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const inlineCss = async opt => {
const { page, pageUrl, options, basePath, browser } = opt;
const minimalcssResult = await minimalcss.minimize({
urls: [pageUrl],
skippable: request =>
options.skipThirdPartyRequests && !request.url().startsWith(basePath),
browser: browser,
userAgent: options.userAgent
});
const criticalCss = minimalcssResult.finalCss;
const criticalCssSize = Buffer.byteLength(criticalCss, "utf8");
const result = await page.evaluate(async () => {
const stylesheets = Array.from(
document.querySelectorAll("link[rel=stylesheet]")
);
const cssArray = await Promise.all(
stylesheets.map(async link => {
const response = await fetch(link.href);
const inlineCss = async opt => {
const { page, pageUrl, options, basePath, browser } = opt;
const minimalcssResult = await minimalcss.minimize({
urls: [pageUrl],
skippable: request =>
options.skipThirdPartyRequests && !request.url().startsWith(basePath),
browser: browser,
userAgent: options.userAgent
});
const criticalCss = minimalcssResult.finalCss;
const criticalCssSize = Buffer.byteLength(criticalCss, "utf8");
const result = await page.evaluate(async () => {
const stylesheets = Array.from(
document.querySelectorAll("link[rel=stylesheet]")
);
const cssArray = await Promise.all(
stylesheets.map(async link => {
const response = await fetch(link.href);