* Inlines critical CSS into the given HTML content. * * @param html The HTML content to process. * @param url The URL associated with the request, for logging purposes. * @returns A promise that resolves to the HTML with inlined critical CSS.
(html: string, url: URL)
| 384 | * @returns A promise that resolves to the HTML with inlined critical CSS. |
| 385 | */ |
| 386 | private async inlineCriticalCss(html: string, url: URL): Promise<string> { |
| 387 | const { inlineCriticalCssProcessor } = this; |
| 388 | |
| 389 | if (!inlineCriticalCssProcessor) { |
| 390 | return html; |
| 391 | } |
| 392 | |
| 393 | try { |
| 394 | return await inlineCriticalCssProcessor.process(html); |
| 395 | } catch (error) { |
| 396 | // eslint-disable-next-line no-console |
| 397 | console.error(`An error occurred while inlining critical CSS for: ${url}.`, error); |
| 398 | |
| 399 | return html; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Inlines critical CSS into the given HTML content. |
no test coverage detected