import type { Check, CheckIssue, PageCheckContext } from '../../types.ts' export function createHtmlSizeCheck(maxSize: number): Check { return { kind: 'page', id: 'performance/html-size', name: 'HTML Size', domain: 'performance', defaultSeverity: 'warning', description: `HTML document should be under ${(maxSize / 1024).toFixed(0)} KB`, essential: false, run(ctx: PageCheckContext): CheckIssue[] { if (ctx.pageData.htmlSize > maxSize) { const actualKB = (ctx.pageData.htmlSize / 1024).toFixed(1) const maxKB = (maxSize / 1024).toFixed(1) return [{ message: `HTML document is ${actualKB} KB (max: ${maxKB} KB)`, suggestion: 'Reduce HTML size by removing unnecessary markup, inlining less CSS, or splitting into multiple pages', actual: `${actualKB} KB`, expected: `<= ${maxKB} KB`, }] } return [] }, } }