[{"data":1,"prerenderedAt":66},["Reactive",2],{"blog-post-markdown-performance-optimization-best-practices-complete-guide":3},{"slug":4,"title":5,"description":6,"excerpt":7,"date":8,"category":9,"author":10,"keywords":11,"readingMinutes":12,"html":13,"headings":14,"tools":40,"related":41},"markdown-performance-optimization-best-practices-complete-guide","Markdown Performance Optimization and Best Practices: Complete Guide for High-Performance Documentation Systems","Master advanced Markdown performance optimization techniques for fast-loading documentation, efficient parsing, and scalable content systems. Learn caching strategies, asset optimization, and performance monitoring for Markdown-based sites.","Advanced Markdown performance optimization and best practices enable high-performance documentation systems that deliver exceptional user experiences while maintaining scalability across large…","2025-11-24","Tutorial","Matthew Rathbone","markdown performance optimization, markdown best practices, documentation performance, markdown parsing optimization, static site performance, markdown caching, content delivery optimization, markdown asset management",28,"\u003Cp>Advanced Markdown performance optimization and best practices enable high-performance documentation systems that deliver exceptional user experiences while maintaining scalability across large content repositories. By implementing sophisticated caching strategies, asset optimization techniques, and performance monitoring systems, technical teams can build lightning-fast Markdown-based platforms that handle massive content volumes efficiently while preserving content quality and maintaining developer productivity.\u003C/p>\n\u003Ch2 id=\"why-master-markdown-performance-optimization\">Why Master Markdown Performance Optimization?\u003C/h2>\n\u003Cp>Professional performance optimization provides essential benefits for content-heavy systems:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>User Experience\u003C/strong>: Deliver instant page loads and smooth navigation across all device types and network conditions\u003C/li>\n\u003Cli>\u003Cstrong>Search Engine Optimization\u003C/strong>: Improve search rankings through faster page speeds and better Core Web Vitals scores\u003C/li>\n\u003Cli>\u003Cstrong>Cost Efficiency\u003C/strong>: Reduce bandwidth usage and server costs through optimized content delivery and caching\u003C/li>\n\u003Cli>\u003Cstrong>Developer Productivity\u003C/strong>: Enable faster build times and development workflows through efficient processing pipelines\u003C/li>\n\u003Cli>\u003Cstrong>Scalability\u003C/strong>: Support massive content repositories without performance degradation or resource bottlenecks\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"foundation-performance-principles\">Foundation Performance Principles\u003C/h2>\n\u003Ch3 id=\"core-performance-metrics-for-markdown-systems\">Core Performance Metrics for Markdown Systems\u003C/h3>\n\u003Cp>Understanding essential performance indicators for documentation platforms:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// performance-monitor.js - Core performance monitoring for Markdown systems\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownPerformanceMonitor\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">parsing\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">fileCount\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">slowestFiles\u003C/span>: []\n            },\n            \u003Cspan class=\"hljs-attr\">rendering\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">pageCount\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">largestPages\u003C/span>: []\n            },\n            \u003Cspan class=\"hljs-attr\">assets\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">imageOptimization\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">cssMinification\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">jsCompression\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">totalSavings\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">caching\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">hitRate\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">missRate\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">cacheSize\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">evictionRate\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n            }\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">thresholds\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">maxParsingTime\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxParsingTime\u003C/span> || \u003Cspan class=\"hljs-number\">100\u003C/span>, \u003Cspan class=\"hljs-comment\">// ms\u003C/span>\n            \u003Cspan class=\"hljs-attr\">maxRenderTime\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxRenderTime\u003C/span> || \u003Cspan class=\"hljs-number\">500\u003C/span>,   \u003Cspan class=\"hljs-comment\">// ms\u003C/span>\n            \u003Cspan class=\"hljs-attr\">maxPageSize\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxPageSize\u003C/span> || \u003Cspan class=\"hljs-number\">1048576\u003C/span>,   \u003Cspan class=\"hljs-comment\">// 1MB\u003C/span>\n            \u003Cspan class=\"hljs-attr\">minCacheHitRate\u003C/span>: options.\u003Cspan class=\"hljs-property\">minCacheHitRate\u003C/span> || \u003Cspan class=\"hljs-number\">0.8\u003C/span> \u003Cspan class=\"hljs-comment\">// 80%\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">startTime\u003C/span> = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">startParsing\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            filePath,\n            \u003Cspan class=\"hljs-attr\">startTime\u003C/span>: performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">endParsing\u003C/span>(\u003Cspan class=\"hljs-params\">parseSession, success = \u003Cspan class=\"hljs-literal\">true\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> duration = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - parseSession.\u003Cspan class=\"hljs-property\">startTime\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> += duration;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">fileCount\u003C/span>++;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">averageTime\u003C/span> = \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">fileCount\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Track slow files\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (duration &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">thresholds\u003C/span>.\u003Cspan class=\"hljs-property\">maxParsingTime\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">slowestFiles\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">filePath\u003C/span>: parseSession.\u003Cspan class=\"hljs-property\">filePath\u003C/span>,\n                duration,\n                \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>()\n            });\n            \n            \u003Cspan class=\"hljs-comment\">// Keep only top 10 slowest files\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">slowestFiles\u003C/span>.\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> b.\u003Cspan class=\"hljs-property\">duration\u003C/span> - a.\u003Cspan class=\"hljs-property\">duration\u003C/span>);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">slowestFiles\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">slowestFiles\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">10\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            duration,\n            success,\n            \u003Cspan class=\"hljs-attr\">filePath\u003C/span>: parseSession.\u003Cspan class=\"hljs-property\">filePath\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">startRendering\u003C/span>(\u003Cspan class=\"hljs-params\">pageId\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            pageId,\n            \u003Cspan class=\"hljs-attr\">startTime\u003C/span>: performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">endRendering\u003C/span>(\u003Cspan class=\"hljs-params\">renderSession, pageSize = \u003Cspan class=\"hljs-number\">0\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> duration = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - renderSession.\u003Cspan class=\"hljs-property\">startTime\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> += duration;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">pageCount\u003C/span>++;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">averageTime\u003C/span> = \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">totalTime\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">pageCount\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Track large pages\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (pageSize &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">thresholds\u003C/span>.\u003Cspan class=\"hljs-property\">maxPageSize\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">largestPages\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">pageId\u003C/span>: renderSession.\u003Cspan class=\"hljs-property\">pageId\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">size\u003C/span>: pageSize,\n                duration,\n                \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>()\n            });\n            \n            \u003Cspan class=\"hljs-comment\">// Keep only top 10 largest pages\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">largestPages\u003C/span>.\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> b.\u003Cspan class=\"hljs-property\">size\u003C/span> - a.\u003Cspan class=\"hljs-property\">size\u003C/span>);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">largestPages\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">largestPages\u003C/span>.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">10\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            duration,\n            pageSize,\n            \u003Cspan class=\"hljs-attr\">pageId\u003C/span>: renderSession.\u003Cspan class=\"hljs-property\">pageId\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">recordAssetOptimization\u003C/span>(\u003Cspan class=\"hljs-params\">type, originalSize, optimizedSize\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> savings = originalSize - optimizedSize;\n        \n        \u003Cspan class=\"hljs-keyword\">switch\u003C/span> (type) {\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;image&#x27;\u003C/span>:\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-property\">imageOptimization\u003C/span> += savings;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;css&#x27;\u003C/span>:\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-property\">cssMinification\u003C/span> += savings;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;js&#x27;\u003C/span>:\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-property\">jsCompression\u003C/span> += savings;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-property\">totalSavings\u003C/span> += savings;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">recordCacheEvent\u003C/span>(\u003Cspan class=\"hljs-params\">event, size = \u003Cspan class=\"hljs-number\">0\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">switch\u003C/span> (event) {\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;hit&#x27;\u003C/span>:\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">hitRate\u003C/span>++;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;miss&#x27;\u003C/span>:\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">missRate\u003C/span>++;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;eviction&#x27;\u003C/span>:\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">evictionRate\u003C/span>++;\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">cacheSize\u003C/span> -= size;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;store&#x27;\u003C/span>:\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">cacheSize\u003C/span> += size;\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generatePerformanceReport\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalRequests = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">hitRate\u003C/span> + \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">missRate\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheHitRate = totalRequests &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">caching\u003C/span>.\u003Cspan class=\"hljs-property\">hitRate\u003C/span> / totalRequests : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> report = {\n            \u003Cspan class=\"hljs-attr\">summary\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalRuntime\u003C/span>: performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">startTime\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">filesProcessed\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">fileCount\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">pagesRendered\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">pageCount\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageParsingTime\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">averageTime\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">averageRenderingTime\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">averageTime\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">cacheHitRate\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(cacheHitRate * \u003Cspan class=\"hljs-number\">100\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">totalAssetSavings\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-property\">totalSavings\u003C/span>)\n            },\n            \u003Cspan class=\"hljs-attr\">issues\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">recommendations\u003C/span>: []\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Identify performance issues\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">averageTime\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">thresholds\u003C/span>.\u003Cspan class=\"hljs-property\">maxParsingTime\u003C/span>) {\n            report.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;slow-parsing&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">`Average parsing time (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Math\u003C/span>.round(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.metrics.parsing.averageTime)}\u003C/span>ms) exceeds threshold (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.thresholds.maxParsingTime}\u003C/span>ms)`\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">affectedFiles\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">parsing\u003C/span>.\u003Cspan class=\"hljs-property\">slowestFiles\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>\n            });\n            \n            report.\u003Cspan class=\"hljs-property\">recommendations\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;parsing&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Optimize Markdown parsing pipeline&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">details\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider implementing parallel processing or caching for frequently parsed files&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">averageTime\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">thresholds\u003C/span>.\u003Cspan class=\"hljs-property\">maxRenderTime\u003C/span>) {\n            report.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;slow-rendering&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">`Average rendering time (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Math\u003C/span>.round(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.metrics.rendering.averageTime)}\u003C/span>ms) exceeds threshold (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.thresholds.maxRenderTime}\u003C/span>ms)`\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">affectedPages\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>.\u003Cspan class=\"hljs-property\">rendering\u003C/span>.\u003Cspan class=\"hljs-property\">largestPages\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>\n            });\n            \n            report.\u003Cspan class=\"hljs-property\">recommendations\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;rendering&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Implement rendering optimizations&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">details\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider template caching, partial rendering, or content splitting&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (cacheHitRate &lt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">thresholds\u003C/span>.\u003Cspan class=\"hljs-property\">minCacheHitRate\u003C/span>) {\n            report.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;low-cache-efficiency&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">`Cache hit rate (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Math\u003C/span>.round(cacheHitRate * \u003Cspan class=\"hljs-number\">100\u003C/span>)}\u003C/span>%) below optimal threshold (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Math\u003C/span>.round(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.thresholds.minCacheHitRate * \u003Cspan class=\"hljs-number\">100\u003C/span>)}\u003C/span>%)`\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">cacheHitRate\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(cacheHitRate * \u003Cspan class=\"hljs-number\">100\u003C/span>)\n            });\n            \n            report.\u003Cspan class=\"hljs-property\">recommendations\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;caching&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Improve caching strategy&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">details\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Review cache invalidation rules and consider increasing cache size or TTL values&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> report;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(\u003Cspan class=\"hljs-params\">bytes\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (bytes === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;0 Bytes&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> k = \u003Cspan class=\"hljs-number\">1024\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sizes = [\u003Cspan class=\"hljs-string\">&#x27;Bytes&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;KB&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;MB&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;GB&#x27;\u003C/span>];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> i = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(bytes) / \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(k));\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-built_in\">parseFloat\u003C/span>((bytes / \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">pow\u003C/span>(k, i)).\u003Cspan class=\"hljs-title function_\">toFixed\u003C/span>(\u003Cspan class=\"hljs-number\">2\u003C/span>)) + \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> + sizes[i];\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">exportMetrics\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">runtime\u003C/span>: performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">startTime\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">metrics\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">thresholds\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">thresholds\u003C/span>\n        };\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">MarkdownPerformanceMonitor\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch3 id=\"advanced-caching-strategies\">Advanced Caching Strategies\u003C/h3>\n\u003Cp>Implementing multi-layer caching systems for optimal performance:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// advanced-cache-manager.js - Sophisticated caching for Markdown systems\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> crypto = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;crypto&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">AdvancedMarkdownCacheManager\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span> = options.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span> || path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(process.\u003Cspan class=\"hljs-title function_\">cwd\u003C/span>(), \u003Cspan class=\"hljs-string\">&#x27;.cache&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxCacheSize\u003C/span> = options.\u003Cspan class=\"hljs-property\">maxCacheSize\u003C/span> || \u003Cspan class=\"hljs-number\">100\u003C/span> * \u003Cspan class=\"hljs-number\">1024\u003C/span> * \u003Cspan class=\"hljs-number\">1024\u003C/span>; \u003Cspan class=\"hljs-comment\">// 100MB\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxFileAge\u003C/span> = options.\u003Cspan class=\"hljs-property\">maxFileAge\u003C/span> || \u003Cspan class=\"hljs-number\">24\u003C/span> * \u003Cspan class=\"hljs-number\">60\u003C/span> * \u003Cspan class=\"hljs-number\">60\u003C/span> * \u003Cspan class=\"hljs-number\">1000\u003C/span>; \u003Cspan class=\"hljs-comment\">// 24 hours\u003C/span>\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">parsed\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),        \u003Cspan class=\"hljs-comment\">// In-memory parsed content cache\u003C/span>\n            \u003Cspan class=\"hljs-attr\">rendered\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),      \u003Cspan class=\"hljs-comment\">// In-memory rendered HTML cache\u003C/span>\n            \u003Cspan class=\"hljs-attr\">assets\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),        \u003Cspan class=\"hljs-comment\">// Asset optimization cache\u003C/span>\n            \u003Cspan class=\"hljs-attr\">metadata\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>()       \u003Cspan class=\"hljs-comment\">// File metadata cache\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">hits\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">misses\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">evictions\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">diskReads\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">diskWrites\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">initialized\u003C/span> = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">initialize\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">initialized\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">mkdir\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">loadDiskCache\u003C/span>();\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">initialized\u003C/span> = \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n            \n            \u003Cspan class=\"hljs-comment\">// Set up periodic cache maintenance\u003C/span>\n            \u003Cspan class=\"hljs-built_in\">setInterval\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">maintainCache\u003C/span>(), \u003Cspan class=\"hljs-number\">5\u003C/span> * \u003Cspan class=\"hljs-number\">60\u003C/span> * \u003Cspan class=\"hljs-number\">1000\u003C/span>); \u003Cspan class=\"hljs-comment\">// Every 5 minutes\u003C/span>\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Failed to initialize cache:&#x27;\u003C/span>, error);\n            \u003Cspan class=\"hljs-keyword\">throw\u003C/span> error;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(\u003Cspan class=\"hljs-params\">content, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> hash = crypto.\u003Cspan class=\"hljs-title function_\">createHash\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;md5&#x27;\u003C/span>);\n        hash.\u003Cspan class=\"hljs-title function_\">update\u003C/span>(content);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (options.\u003Cspan class=\"hljs-property\">includePath\u003C/span>) {\n            hash.\u003Cspan class=\"hljs-title function_\">update\u003C/span>(options.\u003Cspan class=\"hljs-property\">includePath\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (options.\u003Cspan class=\"hljs-property\">includeOptions\u003C/span>) {\n            hash.\u003Cspan class=\"hljs-title function_\">update\u003C/span>(\u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(options.\u003Cspan class=\"hljs-property\">includeOptions\u003C/span>));\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> hash.\u003Cspan class=\"hljs-title function_\">digest\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;hex&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">cacheParseResult\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, content, parseResult\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> key = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(content, { \u003Cspan class=\"hljs-attr\">includePath\u003C/span>: filePath });\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheEntry = {\n            key,\n            filePath,\n            \u003Cspan class=\"hljs-attr\">result\u003C/span>: parseResult,\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">size\u003C/span>: \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(parseResult).\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">contentHash\u003C/span>: crypto.\u003Cspan class=\"hljs-title function_\">createHash\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;md5&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">update\u003C/span>(content).\u003Cspan class=\"hljs-title function_\">digest\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;hex&#x27;\u003C/span>)\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Store in memory cache\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">parsed\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, cacheEntry);\n        \n        \u003Cspan class=\"hljs-comment\">// Store on disk for persistence\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">writeToDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;parsed&#x27;\u003C/span>, key, cacheEntry);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> key;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">getParseResult\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, content\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> key = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(content, { \u003Cspan class=\"hljs-attr\">includePath\u003C/span>: filePath });\n        \n        \u003Cspan class=\"hljs-comment\">// Check memory cache first\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> entry = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">parsed\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(key);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!entry) {\n            \u003Cspan class=\"hljs-comment\">// Check disk cache\u003C/span>\n            entry = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">readFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;parsed&#x27;\u003C/span>, key);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry) {\n                \u003Cspan class=\"hljs-comment\">// Restore to memory cache\u003C/span>\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">parsed\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, entry);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">diskReads\u003C/span>++;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry) {\n            \u003Cspan class=\"hljs-comment\">// Validate cache entry\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> currentHash = crypto.\u003Cspan class=\"hljs-title function_\">createHash\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;md5&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">update\u003C/span>(content).\u003Cspan class=\"hljs-title function_\">digest\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;hex&#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-property\">contentHash\u003C/span> === currentHash &amp;&amp; !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isExpired\u003C/span>(entry)) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>++;\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> entry.\u003Cspan class=\"hljs-property\">result\u003C/span>;\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                \u003Cspan class=\"hljs-comment\">// Invalid cache entry, remove it\u003C/span>\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">parsed\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(key);\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">removeFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;parsed&#x27;\u003C/span>, key);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>++;\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">cacheRenderResult\u003C/span>(\u003Cspan class=\"hljs-params\">contentKey, renderOptions, renderResult\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> key = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(contentKey + \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(renderOptions));\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheEntry = {\n            key,\n            contentKey,\n            renderOptions,\n            \u003Cspan class=\"hljs-attr\">result\u003C/span>: renderResult,\n            \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">size\u003C/span>: renderResult.\u003Cspan class=\"hljs-property\">length\u003C/span> || \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(renderResult).\u003Cspan class=\"hljs-property\">length\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">rendered\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, cacheEntry);\n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">writeToDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;rendered&#x27;\u003C/span>, key, cacheEntry);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> key;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">getRenderResult\u003C/span>(\u003Cspan class=\"hljs-params\">contentKey, renderOptions\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> key = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(contentKey + \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(renderOptions));\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> entry = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">rendered\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(key);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!entry) {\n            entry = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">readFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;rendered&#x27;\u003C/span>, key);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">rendered\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, entry);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">diskReads\u003C/span>++;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry &amp;&amp; !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isExpired\u003C/span>(entry)) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>++;\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> entry.\u003Cspan class=\"hljs-property\">result\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">rendered\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(key);\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">removeFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;rendered&#x27;\u003C/span>, key);\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>++;\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">cacheAssetOptimization\u003C/span>(\u003Cspan class=\"hljs-params\">assetPath, originalSize, optimizedData\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(assetPath);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> key = \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${assetPath}\u003C/span>_\u003Cspan class=\"hljs-subst\">${stats.mtime.getTime()}\u003C/span>_\u003Cspan class=\"hljs-subst\">${stats.size}\u003C/span>`\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheEntry = {\n                key,\n                assetPath,\n                originalSize,\n                optimizedData,\n                \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>(),\n                \u003Cspan class=\"hljs-attr\">size\u003C/span>: optimizedData.\u003Cspan class=\"hljs-property\">length\u003C/span>\n            };\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, cacheEntry);\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">writeToDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;assets&#x27;\u003C/span>, key, cacheEntry);\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> key;\n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Error caching asset optimization:&#x27;\u003C/span>, error);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">getOptimizedAsset\u003C/span>(\u003Cspan class=\"hljs-params\">assetPath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(assetPath);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> key = \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${assetPath}\u003C/span>_\u003Cspan class=\"hljs-subst\">${stats.mtime.getTime()}\u003C/span>_\u003Cspan class=\"hljs-subst\">${stats.size}\u003C/span>`\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> entry = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(key);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!entry) {\n                entry = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">readFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;assets&#x27;\u003C/span>, key);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, entry);\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">diskReads\u003C/span>++;\n                }\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry &amp;&amp; !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isExpired\u003C/span>(entry)) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span>++;\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> entry.\u003Cspan class=\"hljs-property\">optimizedData\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">assets\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(key);\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">removeFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;assets&#x27;\u003C/span>, key);\n            }\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>++;\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Error getting optimized asset:&#x27;\u003C/span>, error);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">isExpired\u003C/span>(\u003Cspan class=\"hljs-params\">entry\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>() - entry.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxFileAge\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">writeToDiskCache\u003C/span>(\u003Cspan class=\"hljs-params\">cacheType, key, entry\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheTypePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, cacheType);\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">mkdir\u003C/span>(cacheTypePath, { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(cacheTypePath, \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${key}\u003C/span>.json`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(filePath, \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">stringify\u003C/span>(entry), \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">diskWrites\u003C/span>++;\n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error writing to disk cache (\u003Cspan class=\"hljs-subst\">${cacheType}\u003C/span>):`\u003C/span>, error);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">readFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-params\">cacheType, key\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, cacheType, \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${key}\u003C/span>.json`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> data = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title class_\">JSON\u003C/span>.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(data);\n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-comment\">// File doesn&#x27;t exist or is corrupted\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">removeFromDiskCache\u003C/span>(\u003Cspan class=\"hljs-params\">cacheType, key\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, cacheType, \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${key}\u003C/span>.json`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">unlink\u003C/span>(filePath);\n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-comment\">// File might not exist, which is fine\u003C/span>\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">loadDiskCache\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheTypes = [\u003Cspan class=\"hljs-string\">&#x27;parsed&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;rendered&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;assets&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;metadata&#x27;\u003C/span>];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheType \u003Cspan class=\"hljs-keyword\">of\u003C/span> cacheTypes) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheTypePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, cacheType);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(cacheTypePath).\u003Cspan class=\"hljs-title function_\">catch\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> []);\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> files) {\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (file.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.json&#x27;\u003C/span>)) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> key = file.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.json&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> entry = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">readFromDiskCache\u003C/span>(cacheType, key);\n                        \n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry &amp;&amp; !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isExpired\u003C/span>(entry)) {\n                            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>[cacheType].\u003Cspan class=\"hljs-title function_\">set\u003C/span>(key, entry);\n                        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry) {\n                            \u003Cspan class=\"hljs-comment\">// Remove expired entry\u003C/span>\n                            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">removeFromDiskCache\u003C/span>(cacheType, key);\n                        }\n                    }\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error loading \u003Cspan class=\"hljs-subst\">${cacheType}\u003C/span> cache:`\u003C/span>, error);\n            }\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">maintainCache\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Running cache maintenance...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> now = \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalEvictions = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Clean up expired entries from all caches\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [cacheType, cache] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>)) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> expiredKeys = [];\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [key, entry] \u003Cspan class=\"hljs-keyword\">of\u003C/span> cache) {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">isExpired\u003C/span>(entry)) {\n                    expiredKeys.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(key);\n                }\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> key \u003Cspan class=\"hljs-keyword\">of\u003C/span> expiredKeys) {\n                cache.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(key);\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">removeFromDiskCache\u003C/span>(cacheType, key);\n                totalEvictions++;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Enforce size limits (LRU eviction)\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">enforceSizeLimits\u003C/span>();\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">evictions\u003C/span> += totalEvictions;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (totalEvictions &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Cache maintenance completed: \u003Cspan class=\"hljs-subst\">${totalEvictions}\u003C/span> expired entries removed`\u003C/span>);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">enforceSizeLimits\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> currentSize = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getCurrentCacheSize\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (currentSize &lt;= \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxCacheSize\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Cache size (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.formatBytes(currentSize)}\u003C/span>) exceeds limit (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.formatBytes(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.maxCacheSize)}\u003C/span>), evicting LRU entries`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Collect all entries with timestamps\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> allEntries = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [cacheType, cache] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>)) {\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [key, entry] \u003Cspan class=\"hljs-keyword\">of\u003C/span> cache) {\n                allEntries.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({ cacheType, key, entry });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Sort by timestamp (oldest first)\u003C/span>\n        allEntries.\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a.\u003Cspan class=\"hljs-property\">entry\u003C/span>.\u003Cspan class=\"hljs-property\">timestamp\u003C/span> - b.\u003Cspan class=\"hljs-property\">entry\u003C/span>.\u003Cspan class=\"hljs-property\">timestamp\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> evictedSize = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> evictedCount = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> { cacheType, key, entry } \u003Cspan class=\"hljs-keyword\">of\u003C/span> allEntries) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (currentSize - evictedSize &lt;= \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxCacheSize\u003C/span> * \u003Cspan class=\"hljs-number\">0.8\u003C/span>) { \u003Cspan class=\"hljs-comment\">// Target 80% of max size\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>[cacheType].\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(key);\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">removeFromDiskCache\u003C/span>(cacheType, key);\n            \n            evictedSize += entry.\u003Cspan class=\"hljs-property\">size\u003C/span> || \u003Cspan class=\"hljs-number\">0\u003C/span>;\n            evictedCount++;\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Evicted \u003Cspan class=\"hljs-subst\">${evictedCount}\u003C/span> entries (\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.formatBytes(evictedSize)}\u003C/span>) to maintain size limit`\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getCurrentCacheSize\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalSize = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> cache \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>)) {\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> entry \u003Cspan class=\"hljs-keyword\">of\u003C/span> cache.\u003Cspan class=\"hljs-title function_\">values\u003C/span>()) {\n                totalSize += entry.\u003Cspan class=\"hljs-property\">size\u003C/span> || \u003Cspan class=\"hljs-number\">0\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> totalSize;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(\u003Cspan class=\"hljs-params\">bytes\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (bytes === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;0 Bytes&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> k = \u003Cspan class=\"hljs-number\">1024\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sizes = [\u003Cspan class=\"hljs-string\">&#x27;Bytes&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;KB&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;MB&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;GB&#x27;\u003C/span>];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> i = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(bytes) / \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(k));\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-built_in\">parseFloat\u003C/span>((bytes / \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">pow\u003C/span>(k, i)).\u003Cspan class=\"hljs-title function_\">toFixed\u003C/span>(\u003Cspan class=\"hljs-number\">2\u003C/span>)) + \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> + sizes[i];\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getStats\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalRequests = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span> + \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">misses\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> hitRate = totalRequests &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">hits\u003C/span> / totalRequests : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            ...\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">hitRate\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(hitRate * \u003Cspan class=\"hljs-number\">100\u003C/span>),\n            totalRequests,\n            \u003Cspan class=\"hljs-attr\">cacheSize\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getCurrentCacheSize\u003C/span>()),\n            \u003Cspan class=\"hljs-attr\">memoryEntries\u003C/span>: \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>).\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, cache\u003C/span>) =&gt;\u003C/span> sum + cache.\u003Cspan class=\"hljs-property\">size\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>)\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">clearCache\u003C/span>(\u003Cspan class=\"hljs-params\">cacheType = \u003Cspan class=\"hljs-literal\">null\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (cacheType) {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>[cacheType].\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n            \n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheTypePath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, cacheType);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(cacheTypePath);\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> files) {\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">unlink\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(cacheTypePath, file));\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error clearing \u003Cspan class=\"hljs-subst\">${cacheType}\u003C/span> cache:`\u003C/span>, error);\n            }\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Clear all caches\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> cache \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-title class_\">Object\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>)) {\n                cache.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">rmdir\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">mkdir\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheDir\u003C/span>, { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Error clearing all caches:&#x27;\u003C/span>, error);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Cache cleared: \u003Cspan class=\"hljs-subst\">${cacheType || \u003Cspan class=\"hljs-string\">&#x27;all&#x27;\u003C/span>}\u003C/span>`\u003C/span>);\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">AdvancedMarkdownCacheManager\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"asset-optimization-and-delivery\">Asset Optimization and Delivery\u003C/h2>\n\u003Ch3 id=\"image-optimization-pipeline\">Image Optimization Pipeline\u003C/h3>\n\u003Cp>Automated image processing for optimal web delivery:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// image-optimization-pipeline.js - Advanced image optimization for Markdown content\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> sharp = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;sharp&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">ImageOptimizationPipeline\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">inputDir\u003C/span> = options.\u003Cspan class=\"hljs-property\">inputDir\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;assets/images&#x27;\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">outputDir\u003C/span> = options.\u003Cspan class=\"hljs-property\">outputDir\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;public/optimized-images&#x27;\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">formats\u003C/span> = options.\u003Cspan class=\"hljs-property\">formats\u003C/span> || [\u003Cspan class=\"hljs-string\">&#x27;webp&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;avif&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;jpeg&#x27;\u003C/span>];\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">qualities\u003C/span> = options.\u003Cspan class=\"hljs-property\">qualities\u003C/span> || { \u003Cspan class=\"hljs-attr\">webp\u003C/span>: \u003Cspan class=\"hljs-number\">80\u003C/span>, \u003Cspan class=\"hljs-attr\">avif\u003C/span>: \u003Cspan class=\"hljs-number\">70\u003C/span>, \u003Cspan class=\"hljs-attr\">jpeg\u003C/span>: \u003Cspan class=\"hljs-number\">85\u003C/span> };\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">sizes\u003C/span> = options.\u003Cspan class=\"hljs-property\">sizes\u003C/span> || [\u003Cspan class=\"hljs-number\">320\u003C/span>, \u003Cspan class=\"hljs-number\">640\u003C/span>, \u003Cspan class=\"hljs-number\">960\u003C/span>, \u003Cspan class=\"hljs-number\">1280\u003C/span>, \u003Cspan class=\"hljs-number\">1920\u003C/span>];\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">enableLazyLoading\u003C/span> = options.\u003Cspan class=\"hljs-property\">enableLazyLoading\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processedImages\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">totalOriginalSize\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalOptimizedSize\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">imagesProcessed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">averageCompressionRatio\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeImagesInContent\u003C/span>(\u003Cspan class=\"hljs-params\">markdownContent, basePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> imageRegex = \u003Cspan class=\"hljs-regexp\">/!\\[([^\\]]*)\\]\\(([^)]+)\\)/g\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> optimizedContent = markdownContent;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> match;\n        \n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = imageRegex.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(markdownContent)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> altText = match[\u003Cspan class=\"hljs-number\">1\u003C/span>];\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> imagePath = match[\u003Cspan class=\"hljs-number\">2\u003C/span>];\n            \n            \u003Cspan class=\"hljs-comment\">// Skip external URLs\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (imagePath.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;http&#x27;\u003C/span>) || imagePath.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;//&#x27;\u003C/span>)) {\n                \u003Cspan class=\"hljs-keyword\">continue\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> fullImagePath = path.\u003Cspan class=\"hljs-title function_\">resolve\u003C/span>(basePath, imagePath);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimizedImageData = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processImage\u003C/span>(fullImagePath, altText);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (optimizedImageData) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> newImageMarkdown = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateOptimizedImageMarkdown\u003C/span>(\n                        optimizedImageData, \n                        altText\n                    );\n                    \n                    optimizedContent = optimizedContent.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(match[\u003Cspan class=\"hljs-number\">0\u003C/span>], newImageMarkdown);\n                }\n                \n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error processing image \u003Cspan class=\"hljs-subst\">${imagePath}\u003C/span>:`\u003C/span>, error);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> optimizedContent;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processImage\u003C/span>(\u003Cspan class=\"hljs-params\">imagePath, altText = \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> imageStats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(imagePath);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> originalSize = imageStats.\u003Cspan class=\"hljs-property\">size\u003C/span>;\n            \n            \u003Cspan class=\"hljs-comment\">// Check cache first\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheKey = \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${imagePath}\u003C/span>_\u003Cspan class=\"hljs-subst\">${imageStats.mtime.getTime()}\u003C/span>_\u003Cspan class=\"hljs-subst\">${imageStats.size}\u003C/span>`\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processedImages\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(cacheKey)) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processedImages\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(cacheKey);\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> imageBuffer = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(imagePath);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> image = \u003Cspan class=\"hljs-title function_\">sharp\u003C/span>(imageBuffer);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> metadata = \u003Cspan class=\"hljs-keyword\">await\u003C/span> image.\u003Cspan class=\"hljs-title function_\">metadata\u003C/span>();\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimizedVersions = [];\n            \n            \u003Cspan class=\"hljs-comment\">// Generate different formats and sizes\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> format \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">formats\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> size \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">sizes\u003C/span>) {\n                    \u003Cspan class=\"hljs-comment\">// Skip if image is smaller than target size\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (metadata.\u003Cspan class=\"hljs-property\">width\u003C/span> &lt; size) \u003Cspan class=\"hljs-keyword\">continue\u003C/span>;\n                    \n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> outputFilename = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateOutputFilename\u003C/span>(\n                        imagePath, \n                        format, \n                        size\n                    );\n                    \n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> outputPath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">outputDir\u003C/span>, outputFilename);\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">mkdir\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(outputPath), { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n                    \n                    \u003Cspan class=\"hljs-keyword\">let\u003C/span> pipeline = image.\u003Cspan class=\"hljs-title function_\">clone\u003C/span>().\u003Cspan class=\"hljs-title function_\">resize\u003C/span>(size, \u003Cspan class=\"hljs-literal\">null\u003C/span>, {\n                        \u003Cspan class=\"hljs-attr\">withoutEnlargement\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">fit\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;inside&#x27;\u003C/span>\n                    });\n                    \n                    \u003Cspan class=\"hljs-comment\">// Apply format-specific optimizations\u003C/span>\n                    \u003Cspan class=\"hljs-keyword\">switch\u003C/span> (format) {\n                        \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;webp&#x27;\u003C/span>:\n                            pipeline = pipeline.\u003Cspan class=\"hljs-title function_\">webp\u003C/span>({ \n                                \u003Cspan class=\"hljs-attr\">quality\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">qualities\u003C/span>.\u003Cspan class=\"hljs-property\">webp\u003C/span>,\n                                \u003Cspan class=\"hljs-attr\">effort\u003C/span>: \u003Cspan class=\"hljs-number\">6\u003C/span> \n                            });\n                            \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                        \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;avif&#x27;\u003C/span>:\n                            pipeline = pipeline.\u003Cspan class=\"hljs-title function_\">avif\u003C/span>({ \n                                \u003Cspan class=\"hljs-attr\">quality\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">qualities\u003C/span>.\u003Cspan class=\"hljs-property\">avif\u003C/span>,\n                                \u003Cspan class=\"hljs-attr\">effort\u003C/span>: \u003Cspan class=\"hljs-number\">4\u003C/span> \n                            });\n                            \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                        \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;jpeg&#x27;\u003C/span>:\n                            pipeline = pipeline.\u003Cspan class=\"hljs-title function_\">jpeg\u003C/span>({ \n                                \u003Cspan class=\"hljs-attr\">quality\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">qualities\u003C/span>.\u003Cspan class=\"hljs-property\">jpeg\u003C/span>,\n                                \u003Cspan class=\"hljs-attr\">progressive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> \n                            });\n                            \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                        \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;png&#x27;\u003C/span>:\n                            pipeline = pipeline.\u003Cspan class=\"hljs-title function_\">png\u003C/span>({ \n                                \u003Cspan class=\"hljs-attr\">compressionLevel\u003C/span>: \u003Cspan class=\"hljs-number\">9\u003C/span>,\n                                \u003Cspan class=\"hljs-attr\">adaptiveFiltering\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> \n                            });\n                            \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                    }\n                    \n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> pipeline.\u003Cspan class=\"hljs-title function_\">toFile\u003C/span>(outputPath);\n                    \n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimizedStats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(outputPath);\n                    \n                    optimizedVersions.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                        format,\n                        size,\n                        \u003Cspan class=\"hljs-attr\">path\u003C/span>: outputPath,\n                        \u003Cspan class=\"hljs-attr\">relativePath\u003C/span>: path.\u003Cspan class=\"hljs-title function_\">relative\u003C/span>(process.\u003Cspan class=\"hljs-title function_\">cwd\u003C/span>(), outputPath),\n                        \u003Cspan class=\"hljs-attr\">fileSize\u003C/span>: optimizedStats.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">compressionRatio\u003C/span>: originalSize / optimizedStats.\u003Cspan class=\"hljs-property\">size\u003C/span>\n                    });\n                }\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Generate thumbnail for lazy loading\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> thumbnailPath = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateThumbnail\u003C/span>(imagePath, image);\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimizedImageData = {\n                \u003Cspan class=\"hljs-attr\">originalPath\u003C/span>: imagePath,\n                originalSize,\n                \u003Cspan class=\"hljs-attr\">versions\u003C/span>: optimizedVersions,\n                \u003Cspan class=\"hljs-attr\">metadata\u003C/span>: {\n                    \u003Cspan class=\"hljs-attr\">width\u003C/span>: metadata.\u003Cspan class=\"hljs-property\">width\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">height\u003C/span>: metadata.\u003Cspan class=\"hljs-property\">height\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">format\u003C/span>: metadata.\u003Cspan class=\"hljs-property\">format\u003C/span>,\n                    altText\n                },\n                \u003Cspan class=\"hljs-attr\">thumbnail\u003C/span>: thumbnailPath,\n                \u003Cspan class=\"hljs-attr\">aspectRatio\u003C/span>: metadata.\u003Cspan class=\"hljs-property\">width\u003C/span> / metadata.\u003Cspan class=\"hljs-property\">height\u003C/span>\n            };\n            \n            \u003Cspan class=\"hljs-comment\">// Update statistics\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> totalOptimizedSize = optimizedVersions.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\n                \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, version\u003C/span>) =&gt;\u003C/span> sum + version.\u003Cspan class=\"hljs-property\">fileSize\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>\n            );\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalOriginalSize\u003C/span> += originalSize;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalOptimizedSize\u003C/span> += totalOptimizedSize;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>.\u003Cspan class=\"hljs-property\">imagesProcessed\u003C/span>++;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>.\u003Cspan class=\"hljs-property\">averageCompressionRatio\u003C/span> = \n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalOriginalSize\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalOptimizedSize\u003C/span>;\n            \n            \u003Cspan class=\"hljs-comment\">// Cache the result\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processedImages\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(cacheKey, optimizedImageData);\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> optimizedImageData;\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error processing image \u003Cspan class=\"hljs-subst\">${imagePath}\u003C/span>:`\u003C/span>, error);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">generateThumbnail\u003C/span>(\u003Cspan class=\"hljs-params\">imagePath, sharpImage\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> thumbnailFilename = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateOutputFilename\u003C/span>(\n                imagePath, \n                \u003Cspan class=\"hljs-string\">&#x27;jpeg&#x27;\u003C/span>, \n                \u003Cspan class=\"hljs-number\">32\u003C/span>, \n                \u003Cspan class=\"hljs-string\">&#x27;thumb&#x27;\u003C/span>\n            );\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> thumbnailPath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">outputDir\u003C/span>, thumbnailFilename);\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">mkdir\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(thumbnailPath), { \u003Cspan class=\"hljs-attr\">recursive\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n            \n            \u003Cspan class=\"hljs-comment\">// Generate tiny, low-quality thumbnail for lazy loading placeholder\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> sharpImage\n                .\u003Cspan class=\"hljs-title function_\">clone\u003C/span>()\n                .\u003Cspan class=\"hljs-title function_\">resize\u003C/span>(\u003Cspan class=\"hljs-number\">32\u003C/span>, \u003Cspan class=\"hljs-literal\">null\u003C/span>, { \n                    \u003Cspan class=\"hljs-attr\">withoutEnlargement\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">fit\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;inside&#x27;\u003C/span> \n                })\n                .\u003Cspan class=\"hljs-title function_\">jpeg\u003C/span>({ \u003Cspan class=\"hljs-attr\">quality\u003C/span>: \u003Cspan class=\"hljs-number\">20\u003C/span> })\n                .\u003Cspan class=\"hljs-title function_\">toFile\u003C/span>(thumbnailPath);\n            \n            \u003Cspan class=\"hljs-comment\">// Convert to base64 for inline embedding\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> thumbnailBuffer = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(thumbnailPath);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> base64Thumbnail = \u003Cspan class=\"hljs-string\">`data:image/jpeg;base64,\u003Cspan class=\"hljs-subst\">${thumbnailBuffer.toString(\u003Cspan class=\"hljs-string\">&#x27;base64&#x27;\u003C/span>)}\u003C/span>`\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> base64Thumbnail;\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Error generating thumbnail:&#x27;\u003C/span>, error);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateOutputFilename\u003C/span>(\u003Cspan class=\"hljs-params\">originalPath, format, size, suffix = \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> parsed = path.\u003Cspan class=\"hljs-title function_\">parse\u003C/span>(originalPath);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> baseName = parsed.\u003Cspan class=\"hljs-property\">name\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> suffixPart = suffix ? \u003Cspan class=\"hljs-string\">`-\u003Cspan class=\"hljs-subst\">${suffix}\u003C/span>`\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${baseName}\u003C/span>-\u003Cspan class=\"hljs-subst\">${size}\u003C/span>w\u003Cspan class=\"hljs-subst\">${suffixPart}\u003C/span>.\u003Cspan class=\"hljs-subst\">${format}\u003C/span>`\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateOptimizedImageMarkdown\u003C/span>(\u003Cspan class=\"hljs-params\">optimizedImageData, altText\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">enableLazyLoading\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generatePictureElement\u003C/span>(optimizedImageData, altText);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateLazyLoadingPicture\u003C/span>(optimizedImageData, altText);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generatePictureElement\u003C/span>(\u003Cspan class=\"hljs-params\">optimizedImageData, altText\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> { versions, metadata, aspectRatio } = optimizedImageData;\n        \n        \u003Cspan class=\"hljs-comment\">// Group versions by format\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> formatGroups = {};\n        versions.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">version\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!formatGroups[version.\u003Cspan class=\"hljs-property\">format\u003C/span>]) {\n                formatGroups[version.\u003Cspan class=\"hljs-property\">format\u003C/span>] = [];\n            }\n            formatGroups[version.\u003Cspan class=\"hljs-property\">format\u003C/span>].\u003Cspan class=\"hljs-title function_\">push\u003C/span>(version);\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> pictureHtml = \u003Cspan class=\"hljs-string\">&#x27;&lt;picture&gt;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Add source elements for modern formats (AVIF, WebP)\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> format \u003Cspan class=\"hljs-keyword\">of\u003C/span> [\u003Cspan class=\"hljs-string\">&#x27;avif&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;webp&#x27;\u003C/span>]) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (formatGroups[format]) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> srcset = formatGroups[format]\n                    .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">v\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${v.relativePath}\u003C/span> \u003Cspan class=\"hljs-subst\">${v.size}\u003C/span>w`\u003C/span>)\n                    .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;, &#x27;\u003C/span>);\n                \n                pictureHtml += \u003Cspan class=\"hljs-string\">`\\n  &lt;source type=&quot;image/\u003Cspan class=\"hljs-subst\">${format}\u003C/span>&quot; srcset=&quot;\u003Cspan class=\"hljs-subst\">${srcset}\u003C/span>&quot; sizes=&quot;(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw&quot;&gt;`\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Add fallback img element\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> jpegVersions = formatGroups[\u003Cspan class=\"hljs-string\">&#x27;jpeg&#x27;\u003C/span>] || formatGroups[\u003Cspan class=\"hljs-string\">&#x27;png&#x27;\u003C/span>] || versions;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> defaultSrc = jpegVersions[\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(jpegVersions.\u003Cspan class=\"hljs-property\">length\u003C/span> / \u003Cspan class=\"hljs-number\">2\u003C/span>)]?.\u003Cspan class=\"hljs-property\">relativePath\u003C/span> || jpegVersions[\u003Cspan class=\"hljs-number\">0\u003C/span>]?.\u003Cspan class=\"hljs-property\">relativePath\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> srcset = jpegVersions\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">v\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${v.relativePath}\u003C/span> \u003Cspan class=\"hljs-subst\">${v.size}\u003C/span>w`\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;, &#x27;\u003C/span>);\n        \n        pictureHtml += \u003Cspan class=\"hljs-string\">`\\n  &lt;img src=&quot;\u003Cspan class=\"hljs-subst\">${defaultSrc}\u003C/span>&quot; srcset=&quot;\u003Cspan class=\"hljs-subst\">${srcset}\u003C/span>&quot; sizes=&quot;(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw&quot; alt=&quot;\u003Cspan class=\"hljs-subst\">${altText}\u003C/span>&quot; loading=&quot;lazy&quot; style=&quot;aspect-ratio: \u003Cspan class=\"hljs-subst\">${aspectRatio}\u003C/span>;&quot;&gt;`\u003C/span>;\n        pictureHtml += \u003Cspan class=\"hljs-string\">&#x27;\\n&lt;/picture&gt;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> pictureHtml;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateLazyLoadingPicture\u003C/span>(\u003Cspan class=\"hljs-params\">optimizedImageData, altText\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> { versions, metadata, thumbnail, aspectRatio } = optimizedImageData;\n        \n        \u003Cspan class=\"hljs-comment\">// Generate IntersectionObserver-based lazy loading\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lazyId = \u003Cspan class=\"hljs-string\">`lazy-\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Date\u003C/span>.now()}\u003C/span>-\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Math\u003C/span>.random().toString(\u003Cspan class=\"hljs-number\">36\u003C/span>).substr(\u003Cspan class=\"hljs-number\">2\u003C/span>, \u003Cspan class=\"hljs-number\">9\u003C/span>)}\u003C/span>`\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> lazyHtml = \u003Cspan class=\"hljs-string\">`&lt;div class=&quot;lazy-image-container&quot; style=&quot;position: relative; aspect-ratio: \u003Cspan class=\"hljs-subst\">${aspectRatio}\u003C/span>;&quot;&gt;`\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Placeholder with thumbnail\u003C/span>\n        lazyHtml += \u003Cspan class=\"hljs-string\">`\\n  &lt;img src=&quot;\u003Cspan class=\"hljs-subst\">${thumbnail}\u003C/span>&quot; alt=&quot;\u003Cspan class=\"hljs-subst\">${altText}\u003C/span>&quot; class=&quot;lazy-placeholder&quot; style=&quot;position: absolute; top: 0; left: 0; width: 100%; height: 100%; filter: blur(10px); transition: opacity 0.3s;&quot;&gt;`\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Actual picture element (initially hidden)\u003C/span>\n        lazyHtml += \u003Cspan class=\"hljs-string\">`\\n  &lt;picture class=&quot;lazy-picture&quot; id=&quot;\u003Cspan class=\"hljs-subst\">${lazyId}\u003C/span>&quot; style=&quot;position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.3s;&quot;&gt;`\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Group versions by format\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> formatGroups = {};\n        versions.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">version\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!formatGroups[version.\u003Cspan class=\"hljs-property\">format\u003C/span>]) {\n                formatGroups[version.\u003Cspan class=\"hljs-property\">format\u003C/span>] = [];\n            }\n            formatGroups[version.\u003Cspan class=\"hljs-property\">format\u003C/span>].\u003Cspan class=\"hljs-title function_\">push\u003C/span>(version);\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Add source elements\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> format \u003Cspan class=\"hljs-keyword\">of\u003C/span> [\u003Cspan class=\"hljs-string\">&#x27;avif&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;webp&#x27;\u003C/span>]) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (formatGroups[format]) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> srcset = formatGroups[format]\n                    .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">v\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${v.relativePath}\u003C/span> \u003Cspan class=\"hljs-subst\">${v.size}\u003C/span>w`\u003C/span>)\n                    .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;, &#x27;\u003C/span>);\n                \n                lazyHtml += \u003Cspan class=\"hljs-string\">`\\n    &lt;source type=&quot;image/\u003Cspan class=\"hljs-subst\">${format}\u003C/span>&quot; data-srcset=&quot;\u003Cspan class=\"hljs-subst\">${srcset}\u003C/span>&quot; sizes=&quot;(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw&quot;&gt;`\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Add fallback img\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> jpegVersions = formatGroups[\u003Cspan class=\"hljs-string\">&#x27;jpeg&#x27;\u003C/span>] || formatGroups[\u003Cspan class=\"hljs-string\">&#x27;png&#x27;\u003C/span>] || versions;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> defaultSrc = jpegVersions[\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(jpegVersions.\u003Cspan class=\"hljs-property\">length\u003C/span> / \u003Cspan class=\"hljs-number\">2\u003C/span>)]?.\u003Cspan class=\"hljs-property\">relativePath\u003C/span> || jpegVersions[\u003Cspan class=\"hljs-number\">0\u003C/span>]?.\u003Cspan class=\"hljs-property\">relativePath\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> srcset = jpegVersions\n            .\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">v\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${v.relativePath}\u003C/span> \u003Cspan class=\"hljs-subst\">${v.size}\u003C/span>w`\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;, &#x27;\u003C/span>);\n        \n        lazyHtml += \u003Cspan class=\"hljs-string\">`\\n    &lt;img data-src=&quot;\u003Cspan class=\"hljs-subst\">${defaultSrc}\u003C/span>&quot; data-srcset=&quot;\u003Cspan class=\"hljs-subst\">${srcset}\u003C/span>&quot; sizes=&quot;(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw&quot; alt=&quot;\u003Cspan class=\"hljs-subst\">${altText}\u003C/span>&quot; style=&quot;width: 100%; height: 100%; object-fit: cover;&quot;&gt;`\u003C/span>;\n        \n        lazyHtml += \u003Cspan class=\"hljs-string\">&#x27;\\n  &lt;/picture&gt;&#x27;\u003C/span>;\n        lazyHtml += \u003Cspan class=\"hljs-string\">&#x27;\\n&lt;/div&gt;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Add intersection observer script\u003C/span>\n        lazyHtml += \u003Cspan class=\"hljs-string\">`\\n&lt;script&gt;\n(function() {\n    const observer = new IntersectionObserver((entries) =&gt; {\n        entries.forEach(entry =&gt; {\n            if (entry.isIntersecting) {\n                const picture = entry.target;\n                const sources = picture.querySelectorAll(&#x27;source[data-srcset]&#x27;);\n                const img = picture.querySelector(&#x27;img[data-src]&#x27;);\n                \n                sources.forEach(source =&gt; {\n                    source.srcset = source.dataset.srcset;\n                });\n                \n                if (img) {\n                    img.src = img.dataset.src;\n                    if (img.dataset.srcset) {\n                        img.srcset = img.dataset.srcset;\n                    }\n                }\n                \n                img.onload = () =&gt; {\n                    picture.style.opacity = &#x27;1&#x27;;\n                    const placeholder = picture.parentElement.querySelector(&#x27;.lazy-placeholder&#x27;);\n                    if (placeholder) {\n                        placeholder.style.opacity = &#x27;0&#x27;;\n                    }\n                };\n                \n                observer.unobserve(picture);\n            }\n        });\n    }, { threshold: 0.1 });\n    \n    const picture = document.getElementById(&#x27;\u003Cspan class=\"hljs-subst\">${lazyId}\u003C/span>&#x27;);\n    if (picture) observer.observe(picture);\n})();\n&lt;/script&gt;`\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> lazyHtml;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">generateOptimizationReport\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">summary\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">imagesProcessed\u003C/span>: stats.\u003Cspan class=\"hljs-property\">imagesProcessed\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">originalTotalSize\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(stats.\u003Cspan class=\"hljs-property\">totalOriginalSize\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">optimizedTotalSize\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(stats.\u003Cspan class=\"hljs-property\">totalOptimizedSize\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">totalSavings\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(stats.\u003Cspan class=\"hljs-property\">totalOriginalSize\u003C/span> - stats.\u003Cspan class=\"hljs-property\">totalOptimizedSize\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">averageCompressionRatio\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(stats.\u003Cspan class=\"hljs-property\">averageCompressionRatio\u003C/span> * \u003Cspan class=\"hljs-number\">100\u003C/span>) / \u003Cspan class=\"hljs-number\">100\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">spaceSavingsPercent\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>((\u003Cspan class=\"hljs-number\">1\u003C/span> - stats.\u003Cspan class=\"hljs-property\">totalOptimizedSize\u003C/span> / stats.\u003Cspan class=\"hljs-property\">totalOriginalSize\u003C/span>) * \u003Cspan class=\"hljs-number\">100\u003C/span>)\n            },\n            \u003Cspan class=\"hljs-attr\">processedImages\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processedImages\u003C/span>.\u003Cspan class=\"hljs-title function_\">entries\u003C/span>()).\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">[key, data]\u003C/span>) =&gt;\u003C/span> ({\n                \u003Cspan class=\"hljs-attr\">originalPath\u003C/span>: data.\u003Cspan class=\"hljs-property\">originalPath\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">originalSize\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(data.\u003Cspan class=\"hljs-property\">originalSize\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">versions\u003C/span>: data.\u003Cspan class=\"hljs-property\">versions\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">formats\u003C/span>: [...\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>(data.\u003Cspan class=\"hljs-property\">versions\u003C/span>.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">v\u003C/span> =&gt;\u003C/span> v.\u003Cspan class=\"hljs-property\">format\u003C/span>))],\n                \u003Cspan class=\"hljs-attr\">sizes\u003C/span>: [...\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Set\u003C/span>(data.\u003Cspan class=\"hljs-property\">versions\u003C/span>.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">v\u003C/span> =&gt;\u003C/span> v.\u003Cspan class=\"hljs-property\">size\u003C/span>))].\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a - b)\n            })),\n            \u003Cspan class=\"hljs-attr\">recommendations\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateOptimizationRecommendations\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateOptimizationRecommendations\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recommendations = [];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">optimizationStats\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (stats.\u003Cspan class=\"hljs-property\">averageCompressionRatio\u003C/span> &lt; \u003Cspan class=\"hljs-number\">2\u003C/span>) {\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;compression&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider more aggressive compression settings - current average compression ratio is low&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">suggestion\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Review quality settings and consider additional format conversions&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (stats.\u003Cspan class=\"hljs-property\">imagesProcessed\u003C/span> &gt; \u003Cspan class=\"hljs-number\">100\u003C/span> &amp;&amp; stats.\u003Cspan class=\"hljs-property\">totalOriginalSize\u003C/span> &gt; \u003Cspan class=\"hljs-number\">50\u003C/span> * \u003Cspan class=\"hljs-number\">1024\u003C/span> * \u003Cspan class=\"hljs-number\">1024\u003C/span>) { \u003Cspan class=\"hljs-comment\">// 50MB\u003C/span>\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;cdn&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Large number of images detected - consider using a CDN&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">suggestion\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Implement a CDN solution to improve image delivery performance globally&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> recommendations;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">formatBytes\u003C/span>(\u003Cspan class=\"hljs-params\">bytes\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (bytes === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;0 Bytes&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> k = \u003Cspan class=\"hljs-number\">1024\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sizes = [\u003Cspan class=\"hljs-string\">&#x27;Bytes&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;KB&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;MB&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;GB&#x27;\u003C/span>];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> i = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(\u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(bytes) / \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(k));\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-built_in\">parseFloat\u003C/span>((bytes / \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">pow\u003C/span>(k, i)).\u003Cspan class=\"hljs-title function_\">toFixed\u003C/span>(\u003Cspan class=\"hljs-number\">2\u003C/span>)) + \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> + sizes[i];\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">ImageOptimizationPipeline\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"build-process-optimization\">Build Process Optimization\u003C/h2>\n\u003Ch3 id=\"parallel-processing-and-build-pipeline\">Parallel Processing and Build Pipeline\u003C/h3>\n\u003Cp>Maximizing build performance through intelligent processing strategies:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// build-optimizer.js - Advanced build optimization for Markdown systems\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> { \u003Cspan class=\"hljs-title class_\">Worker\u003C/span> } = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;worker_threads&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> os = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;os&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownBuildOptimizer\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxWorkers\u003C/span> = options.\u003Cspan class=\"hljs-property\">maxWorkers\u003C/span> || os.\u003Cspan class=\"hljs-title function_\">cpus\u003C/span>().\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">chunkSize\u003C/span> = options.\u003Cspan class=\"hljs-property\">chunkSize\u003C/span> || \u003Cspan class=\"hljs-number\">10\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">enableIncrementalBuilds\u003C/span> = options.\u003Cspan class=\"hljs-property\">enableIncrementalBuilds\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheManager\u003C/span> = options.\u003Cspan class=\"hljs-property\">cacheManager\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">performanceMonitor\u003C/span> = options.\u003Cspan class=\"hljs-property\">performanceMonitor\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span> = [];\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildQueue\u003C/span> = [];\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">totalFiles\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">processedFiles\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">skippedFiles\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">errors\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">startTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">endTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">initializeWorkers\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Initializing \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.maxWorkers}\u003C/span> worker threads...`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxWorkers\u003C/span>; i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> worker = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Worker\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(__dirname, \u003Cspan class=\"hljs-string\">&#x27;markdown-worker.js&#x27;\u003C/span>));\n            \n            worker.\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;message&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">message\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleWorkerMessage\u003C/span>(worker, message);\n            });\n            \n            worker.\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">error\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Worker \u003Cspan class=\"hljs-subst\">${worker.threadId}\u003C/span> error:`\u003C/span>, error);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleWorkerError\u003C/span>(worker, error);\n            });\n            \n            worker.\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;exit&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">code\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (code !== \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Worker \u003Cspan class=\"hljs-subst\">${worker.threadId}\u003C/span> exited with code \u003Cspan class=\"hljs-subst\">${code}\u003C/span>`\u003C/span>);\n                }\n            });\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                worker,\n                \u003Cspan class=\"hljs-attr\">busy\u003C/span>: \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">currentJob\u003C/span>: \u003Cspan class=\"hljs-literal\">null\u003C/span>\n            });\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">buildContent\u003C/span>(\u003Cspan class=\"hljs-params\">files, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">startTime\u003C/span> = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalFiles\u003C/span> = files.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">processedFiles\u003C/span> = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">skippedFiles\u003C/span> = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span> = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Starting build for \u003Cspan class=\"hljs-subst\">${files.length}\u003C/span> files with \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.maxWorkers}\u003C/span> workers`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Filter files for incremental builds\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> filesToProcess = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">filterFilesForIncremental\u003C/span>(files);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">skippedFiles\u003C/span> = files.\u003Cspan class=\"hljs-property\">length\u003C/span> - filesToProcess.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (filesToProcess.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;No files need processing (incremental build)&#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n                \u003Cspan class=\"hljs-attr\">success\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">stats\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">results\u003C/span>: []\n            };\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Split files into chunks for better load balancing\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileChunks = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">chunkArray\u003C/span>(filesToProcess, \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">chunkSize\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Process chunks in parallel\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processChunksInParallel\u003C/span>(fileChunks, options);\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">endTime\u003C/span> = performance.\u003Cspan class=\"hljs-title function_\">now\u003C/span>();\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Build completed in \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Math\u003C/span>.round(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.buildStats.endTime - \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.buildStats.startTime)}\u003C/span>ms`\u003C/span>);\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Processed: \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.buildStats.processedFiles}\u003C/span>, Skipped: \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.buildStats.skippedFiles}\u003C/span>, Errors: \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.buildStats.errors}\u003C/span>`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">success\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">stats\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">results\u003C/span>: results.\u003Cspan class=\"hljs-title function_\">flat\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">filterFilesForIncremental\u003C/span>(\u003Cspan class=\"hljs-params\">files\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">enableIncrementalBuilds\u003C/span> || !\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheManager\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> files;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> filesToProcess = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> file \u003Cspan class=\"hljs-keyword\">of\u003C/span> files) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> needsRebuild = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">fileNeedsRebuild\u003C/span>(file);\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (needsRebuild) {\n                    filesToProcess.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(file);\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error checking file \u003Cspan class=\"hljs-subst\">${file}\u003C/span>:`\u003C/span>, error);\n                \u003Cspan class=\"hljs-comment\">// Include file in processing if we can&#x27;t determine its state\u003C/span>\n                filesToProcess.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(file);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Incremental build: \u003Cspan class=\"hljs-subst\">${filesToProcess.length}\u003C/span>/\u003Cspan class=\"hljs-subst\">${files.length}\u003C/span> files need processing`\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> filesToProcess;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">fileNeedsRebuild\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(filePath);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-comment\">// Check if we have a cached result\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cachedResult = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheManager\u003C/span>.\u003Cspan class=\"hljs-title function_\">getParseResult\u003C/span>(filePath, content);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!cachedResult) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>; \u003Cspan class=\"hljs-comment\">// No cache, needs processing\u003C/span>\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check if file modification time is newer than cache\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheKey = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheManager\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateCacheKey\u003C/span>(content, { \u003Cspan class=\"hljs-attr\">includePath\u003C/span>: filePath });\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> cacheEntry = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">cacheManager\u003C/span>.\u003Cspan class=\"hljs-property\">caches\u003C/span>.\u003Cspan class=\"hljs-property\">parsed\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(cacheKey);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!cacheEntry || stats.\u003Cspan class=\"hljs-property\">mtime\u003C/span>.\u003Cspan class=\"hljs-title function_\">getTime\u003C/span>() &gt; cacheEntry.\u003Cspan class=\"hljs-property\">timestamp\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>; \u003Cspan class=\"hljs-comment\">// File modified since cache\u003C/span>\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check dependencies (images, includes, etc.)\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">checkDependencyChanges\u003C/span>(filePath, content, cacheEntry.\u003Cspan class=\"hljs-property\">timestamp\u003C/span>);\n            \n        } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n            \u003Cspan class=\"hljs-comment\">// If we can&#x27;t check, assume it needs rebuilding\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">checkDependencyChanges\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, content, cacheTimestamp\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> basePath = path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(filePath);\n        \n        \u003Cspan class=\"hljs-comment\">// Check image dependencies\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> imageRegex = \u003Cspan class=\"hljs-regexp\">/!\\[([^\\]]*)\\]\\(([^)]+)\\)/g\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> match;\n        \n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = imageRegex.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(content)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> imagePath = match[\u003Cspan class=\"hljs-number\">2\u003C/span>];\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (imagePath.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;http&#x27;\u003C/span>) || imagePath.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;//&#x27;\u003C/span>)) {\n                \u003Cspan class=\"hljs-keyword\">continue\u003C/span>; \u003Cspan class=\"hljs-comment\">// Skip external images\u003C/span>\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> fullImagePath = path.\u003Cspan class=\"hljs-title function_\">resolve\u003C/span>(basePath, imagePath);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> imageStats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(fullImagePath);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (imageStats.\u003Cspan class=\"hljs-property\">mtime\u003C/span>.\u003Cspan class=\"hljs-title function_\">getTime\u003C/span>() &gt; cacheTimestamp) {\n                    \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>; \u003Cspan class=\"hljs-comment\">// Dependency changed\u003C/span>\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-comment\">// Image might not exist, but that&#x27;s a change too\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Check include dependencies (if your system supports includes)\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> includeRegex = \u003Cspan class=\"hljs-regexp\">/\\{\\{&gt;\\s*([^}]+)\\}\\}/g\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = includeRegex.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(content)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> includePath = match[\u003Cspan class=\"hljs-number\">1\u003C/span>].\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n            \n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> fullIncludePath = path.\u003Cspan class=\"hljs-title function_\">resolve\u003C/span>(basePath, includePath);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> includeStats = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">stat\u003C/span>(fullIncludePath);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (includeStats.\u003Cspan class=\"hljs-property\">mtime\u003C/span>.\u003Cspan class=\"hljs-title function_\">getTime\u003C/span>() &gt; cacheTimestamp) {\n                    \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>; \u003Cspan class=\"hljs-comment\">// Include changed\u003C/span>\n                }\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">false\u003C/span>; \u003Cspan class=\"hljs-comment\">// No dependencies changed\u003C/span>\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processChunksInParallel\u003C/span>(\u003Cspan class=\"hljs-params\">chunks, options\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">resolve, reject\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> completedChunks = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> hasError = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Array\u003C/span>(chunks.\u003Cspan class=\"hljs-property\">length\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> \u003Cspan class=\"hljs-title function_\">processNextChunk\u003C/span> = (\u003Cspan class=\"hljs-params\">\u003C/span>) =&gt; {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> availableWorker = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span>.\u003Cspan class=\"hljs-title function_\">find\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">w\u003C/span> =&gt;\u003C/span> !w.\u003Cspan class=\"hljs-property\">busy\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> nextChunkIndex = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildQueue\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (nextChunkIndex &lt; chunks.\u003Cspan class=\"hljs-property\">length\u003C/span> &amp;&amp; availableWorker &amp;&amp; !hasError) {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> chunk = chunks[nextChunkIndex];\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildQueue\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(chunk);\n                    \n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">assignJobToWorker\u003C/span>(availableWorker, {\n                        \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;process-chunk&#x27;\u003C/span>,\n                        chunk,\n                        \u003Cspan class=\"hljs-attr\">chunkIndex\u003C/span>: nextChunkIndex,\n                        options\n                    }).\u003Cspan class=\"hljs-title function_\">then\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">result\u003C/span>) =&gt;\u003C/span> {\n                        results[nextChunkIndex] = result;\n                        completedChunks++;\n                        \n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (completedChunks === chunks.\u003Cspan class=\"hljs-property\">length\u003C/span>) {\n                            \u003Cspan class=\"hljs-title function_\">resolve\u003C/span>(results);\n                        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                            \u003Cspan class=\"hljs-title function_\">processNextChunk\u003C/span>();\n                        }\n                    }).\u003Cspan class=\"hljs-title function_\">catch\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">error\u003C/span>) =&gt;\u003C/span> {\n                        hasError = \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n                        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>++;\n                        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Chunk processing error:&#x27;\u003C/span>, error);\n                        \n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!hasError) { \u003Cspan class=\"hljs-comment\">// Only reject once\u003C/span>\n                            \u003Cspan class=\"hljs-title function_\">reject\u003C/span>(error);\n                        }\n                    });\n                    \n                    \u003Cspan class=\"hljs-comment\">// Try to start more jobs\u003C/span>\n                    \u003Cspan class=\"hljs-title function_\">setImmediate\u003C/span>(processNextChunk);\n                }\n            };\n            \n            \u003Cspan class=\"hljs-comment\">// Start initial jobs\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">min\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxWorkers\u003C/span>, chunks.\u003Cspan class=\"hljs-property\">length\u003C/span>); i++) {\n                \u003Cspan class=\"hljs-title function_\">processNextChunk\u003C/span>();\n            }\n        });\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">assignJobToWorker\u003C/span>(\u003Cspan class=\"hljs-params\">workerInfo, job\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">resolve, reject\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> jobId = \u003Cspan class=\"hljs-string\">`job_\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Date\u003C/span>.now()}\u003C/span>_\u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">Math\u003C/span>.random().toString(\u003Cspan class=\"hljs-number\">36\u003C/span>).substr(\u003Cspan class=\"hljs-number\">2\u003C/span>, \u003Cspan class=\"hljs-number\">9\u003C/span>)}\u003C/span>`\u003C/span>;\n            \n            workerInfo.\u003Cspan class=\"hljs-property\">busy\u003C/span> = \u003Cspan class=\"hljs-literal\">true\u003C/span>;\n            workerInfo.\u003Cspan class=\"hljs-property\">currentJob\u003C/span> = { ...job, jobId, resolve, reject };\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(jobId, workerInfo);\n            \n            workerInfo.\u003Cspan class=\"hljs-property\">worker\u003C/span>.\u003Cspan class=\"hljs-title function_\">postMessage\u003C/span>({ jobId, ...job });\n            \n            \u003Cspan class=\"hljs-comment\">// Set timeout for job\u003C/span>\n            \u003Cspan class=\"hljs-built_in\">setTimeout\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(jobId)) {\n                    \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Job \u003Cspan class=\"hljs-subst\">${jobId}\u003C/span> timed out`\u003C/span>);\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">handleJobTimeout\u003C/span>(jobId);\n                }\n            }, \u003Cspan class=\"hljs-number\">30000\u003C/span>); \u003Cspan class=\"hljs-comment\">// 30 second timeout\u003C/span>\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">handleWorkerMessage\u003C/span>(\u003Cspan class=\"hljs-params\">worker, message\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> { jobId, type, result, error } = message;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> workerInfo = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(jobId);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!workerInfo) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Received message for unknown job: \u003Cspan class=\"hljs-subst\">${jobId}\u003C/span>`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        }\n        \n        workerInfo.\u003Cspan class=\"hljs-property\">busy\u003C/span> = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n        workerInfo.\u003Cspan class=\"hljs-property\">currentJob\u003C/span> = \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(jobId);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (error) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Worker job \u003Cspan class=\"hljs-subst\">${jobId}\u003C/span> failed:`\u003C/span>, error);\n            workerInfo.\u003Cspan class=\"hljs-property\">currentJob\u003C/span>?.\u003Cspan class=\"hljs-title function_\">reject\u003C/span>(\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Error\u003C/span>(error));\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>++;\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">processedFiles\u003C/span> += result.\u003Cspan class=\"hljs-property\">processedCount\u003C/span> || \u003Cspan class=\"hljs-number\">0\u003C/span>;\n            workerInfo.\u003Cspan class=\"hljs-property\">currentJob\u003C/span>?.\u003Cspan class=\"hljs-title function_\">resolve\u003C/span>(result);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">handleWorkerError\u003C/span>(\u003Cspan class=\"hljs-params\">worker, error\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Find and clean up any active jobs for this worker\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [jobId, workerInfo] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (workerInfo.\u003Cspan class=\"hljs-property\">worker\u003C/span> === worker) {\n                workerInfo.\u003Cspan class=\"hljs-property\">currentJob\u003C/span>?.\u003Cspan class=\"hljs-title function_\">reject\u003C/span>(error);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(jobId);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>++;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Mark worker as not busy so it can be restarted if needed\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> workerInfo = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span>.\u003Cspan class=\"hljs-title function_\">find\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">w\u003C/span> =&gt;\u003C/span> w.\u003Cspan class=\"hljs-property\">worker\u003C/span> === worker);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (workerInfo) {\n            workerInfo.\u003Cspan class=\"hljs-property\">busy\u003C/span> = \u003Cspan class=\"hljs-literal\">false\u003C/span>;\n            workerInfo.\u003Cspan class=\"hljs-property\">currentJob\u003C/span> = \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">handleJobTimeout\u003C/span>(\u003Cspan class=\"hljs-params\">jobId\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> workerInfo = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(jobId);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (workerInfo) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Terminating worker due to job timeout: \u003Cspan class=\"hljs-subst\">${jobId}\u003C/span>`\u003C/span>);\n            \n            workerInfo.\u003Cspan class=\"hljs-property\">currentJob\u003C/span>?.\u003Cspan class=\"hljs-title function_\">reject\u003C/span>(\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Error\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Job timeout&#x27;\u003C/span>));\n            workerInfo.\u003Cspan class=\"hljs-property\">worker\u003C/span>.\u003Cspan class=\"hljs-title function_\">terminate\u003C/span>();\n            \n            \u003Cspan class=\"hljs-comment\">// Remove from workers array and create new worker\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> index = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span>.\u003Cspan class=\"hljs-title function_\">indexOf\u003C/span>(workerInfo);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (index !== -\u003Cspan class=\"hljs-number\">1\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span>.\u003Cspan class=\"hljs-title function_\">splice\u003C/span>(index, \u003Cspan class=\"hljs-number\">1\u003C/span>);\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">initializeWorkers\u003C/span>(); \u003Cspan class=\"hljs-comment\">// This will add a new worker\u003C/span>\n            }\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">delete\u003C/span>(jobId);\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>++;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">chunkArray\u003C/span>(\u003Cspan class=\"hljs-params\">array, chunkSize\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> chunks = [];\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; array.\u003Cspan class=\"hljs-property\">length\u003C/span>; i += chunkSize) {\n            chunks.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(array.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(i, i + chunkSize));\n        }\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> chunks;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">cleanup\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Cleaning up workers...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> terminationPromises = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span>.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">workerInfo\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">resolve\u003C/span>) =&gt;\u003C/span> {\n                workerInfo.\u003Cspan class=\"hljs-property\">worker\u003C/span>.\u003Cspan class=\"hljs-title function_\">once\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;exit&#x27;\u003C/span>, resolve);\n                workerInfo.\u003Cspan class=\"hljs-property\">worker\u003C/span>.\u003Cspan class=\"hljs-title function_\">terminate\u003C/span>();\n            });\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title class_\">Promise\u003C/span>.\u003Cspan class=\"hljs-title function_\">all\u003C/span>(terminationPromises);\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">workers\u003C/span> = [];\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">activeJobs\u003C/span>.\u003Cspan class=\"hljs-title function_\">clear\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateBuildReport\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> duration = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">endTime\u003C/span> - \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">startTime\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> filesPerSecond = duration &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">processedFiles\u003C/span> / (duration / \u003Cspan class=\"hljs-number\">1000\u003C/span>)).\u003Cspan class=\"hljs-title function_\">toFixed\u003C/span>(\u003Cspan class=\"hljs-number\">2\u003C/span>) : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">duration\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(duration),\n            \u003Cspan class=\"hljs-attr\">filesProcessed\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">processedFiles\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">filesSkipped\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">skippedFiles\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">errors\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">errors\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">filesPerSecond\u003C/span>: \u003Cspan class=\"hljs-built_in\">parseFloat\u003C/span>(filesPerSecond),\n            \u003Cspan class=\"hljs-attr\">efficiency\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">incrementalBuildEnabled\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">enableIncrementalBuilds\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">cacheHitRate\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">skippedFiles\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">totalFiles\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">parallelizationRatio\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">maxWorkers\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageChunkSize\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">chunkSize\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">recommendations\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateBuildRecommendations\u003C/span>()\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateBuildRecommendations\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> recommendations = [];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> stats = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (stats.\u003Cspan class=\"hljs-property\">errors\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;errors&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${stats.errors}\u003C/span> files failed to process`\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Review error logs and fix content issues&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (stats.\u003Cspan class=\"hljs-property\">processedFiles\u003C/span> &gt; stats.\u003Cspan class=\"hljs-property\">skippedFiles\u003C/span> * \u003Cspan class=\"hljs-number\">2\u003C/span>) {\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;caching&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Low cache efficiency detected&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Review incremental build configuration and cache invalidation rules&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> duration = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">endTime\u003C/span> - \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">startTime\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> filesPerSecond = duration &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">processedFiles\u003C/span> / (duration / \u003Cspan class=\"hljs-number\">1000\u003C/span>) : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (filesPerSecond &lt; \u003Cspan class=\"hljs-number\">5\u003C/span> &amp;&amp; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">buildStats\u003C/span>.\u003Cspan class=\"hljs-property\">processedFiles\u003C/span> &gt; \u003Cspan class=\"hljs-number\">50\u003C/span>) {\n            recommendations.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;performance&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Slow processing speed detected&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">action\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider increasing worker count or optimizing content parsing&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> recommendations;\n    }\n}\n\n\u003Cspan class=\"hljs-comment\">// Worker thread script would be in a separate file (markdown-worker.js)\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> workerScript = \u003Cspan class=\"hljs-string\">`\nconst { parentPort } = require(&#x27;worker_threads&#x27;);\nconst fs = require(&#x27;fs&#x27;).promises;\nconst path = require(&#x27;path&#x27;);\n\n// Mock markdown processor - replace with your actual processor\nclass MarkdownProcessor {\n    async processFile(filePath, options = {}) {\n        try {\n            const content = await fs.readFile(filePath, &#x27;utf8&#x27;);\n            \n            // Simulate processing time based on content length\n            await new Promise(resolve =&gt; \n                setTimeout(resolve, Math.min(content.length / 1000, 100))\n            );\n            \n            // Mock processing result\n            return {\n                filePath,\n                html: content.replace(/\\\\*\\\\*(.+?)\\\\*\\\\*/g, &#x27;&lt;strong&gt;$1&lt;/strong&gt;&#x27;),\n                wordCount: content.split(/\\\\s+/).length,\n                processingTime: Date.now()\n            };\n            \n        } catch (error) {\n            throw new Error(\\`Failed to process \\${filePath}: \\${error.message}\\`);\n        }\n    }\n}\n\nconst processor = new MarkdownProcessor();\n\nparentPort.on(&#x27;message&#x27;, async (message) =&gt; {\n    const { jobId, type, chunk, options } = message;\n    \n    try {\n        if (type === &#x27;process-chunk&#x27;) {\n            const results = [];\n            \n            for (const filePath of chunk) {\n                try {\n                    const result = await processor.processFile(filePath, options);\n                    results.push(result);\n                } catch (error) {\n                    results.push({\n                        filePath,\n                        error: error.message,\n                        failed: true\n                    });\n                }\n            }\n            \n            parentPort.postMessage({\n                jobId,\n                type: &#x27;chunk-complete&#x27;,\n                result: {\n                    processedCount: results.length,\n                    results\n                }\n            });\n            \n        } else {\n            throw new Error(\\`Unknown job type: \\${type}\\`);\n        }\n        \n    } catch (error) {\n        parentPort.postMessage({\n            jobId,\n            type: &#x27;error&#x27;,\n            error: error.message\n        });\n    }\n});\n`\u003C/span>;\n\n\u003Cspan class=\"hljs-comment\">// Write worker script to file during initialization\u003C/span>\n\u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-title function_\">writeFileSync\u003C/span>(\n    path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(__dirname, \u003Cspan class=\"hljs-string\">&#x27;markdown-worker.js&#x27;\u003C/span>), \n    workerScript\n);\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">MarkdownBuildOptimizer\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"performance-integration-with-documentation-systems\">Performance Integration with Documentation Systems\u003C/h2>\n\u003Cp>Performance optimization strategies integrate seamlessly with comprehensive documentation workflows. When combined with \u003Ca href=\"/blog/markdown-automation-workflows-complete-guide\">automation systems and CI/CD pipelines\u003C/a>, performance monitoring becomes part of the continuous integration process, ensuring optimal site performance is maintained automatically as content scales and user traffic increases.\u003C/p>\n\u003Cp>For advanced content management, performance optimization works effectively with \u003Ca href=\"/blog/markdown-progressive-web-app-documentation-complete-guide\">Progressive Web App documentation systems\u003C/a> to create lightning-fast offline-capable documentation experiences that provide exceptional user experiences regardless of network conditions or device capabilities.\u003C/p>\n\u003Cp>When building sophisticated content architectures, performance optimization complements \u003Ca href=\"/blog/markdown-version-control-git-integration-complete-guide\">version control and Git integration systems\u003C/a> by enabling performance-aware content workflows where build optimization and deployment strategies automatically adapt based on content changes and performance metrics.\u003C/p>\n\u003Ch2 id=\"advanced-performance-monitoring-and-analytics\">Advanced Performance Monitoring and Analytics\u003C/h2>\n\u003Ch3 id=\"real-time-performance-dashboard\">Real-Time Performance Dashboard\u003C/h3>\n\u003Cp>Comprehensive performance monitoring for production Markdown systems:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// performance-dashboard.js - Real-time performance monitoring system\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MarkdownPerformanceDashboard\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metricsCollector\u003C/span> = options.\u003Cspan class=\"hljs-property\">metricsCollector\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">pageLoadTime\u003C/span>: options.\u003Cspan class=\"hljs-property\">pageLoadThreshold\u003C/span> || \u003Cspan class=\"hljs-number\">3000\u003C/span>, \u003Cspan class=\"hljs-comment\">// 3 seconds\u003C/span>\n            \u003Cspan class=\"hljs-attr\">coreWebVitals\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">lcp\u003C/span>: options.\u003Cspan class=\"hljs-property\">lcpThreshold\u003C/span> || \u003Cspan class=\"hljs-number\">2500\u003C/span>,  \u003Cspan class=\"hljs-comment\">// Largest Contentful Paint\u003C/span>\n                \u003Cspan class=\"hljs-attr\">fid\u003C/span>: options.\u003Cspan class=\"hljs-property\">fidThreshold\u003C/span> || \u003Cspan class=\"hljs-number\">100\u003C/span>,   \u003Cspan class=\"hljs-comment\">// First Input Delay\u003C/span>\n                \u003Cspan class=\"hljs-attr\">cls\u003C/span>: options.\u003Cspan class=\"hljs-property\">clsThreshold\u003C/span> || \u003Cspan class=\"hljs-number\">0.1\u003C/span>    \u003Cspan class=\"hljs-comment\">// Cumulative Layout Shift\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">buildTime\u003C/span>: options.\u003Cspan class=\"hljs-property\">buildThreshold\u003C/span> || \u003Cspan class=\"hljs-number\">300000\u003C/span>, \u003Cspan class=\"hljs-comment\">// 5 minutes\u003C/span>\n            \u003Cspan class=\"hljs-attr\">cacheHitRate\u003C/span>: options.\u003Cspan class=\"hljs-property\">cacheThreshold\u003C/span> || \u003Cspan class=\"hljs-number\">0.8\u003C/span>  \u003Cspan class=\"hljs-comment\">// 80%\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">metrics\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">realTime\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">activeUsers\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">pageViews\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">avgLoadTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">errorRate\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">build\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">lastBuildTime\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">buildSuccess\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">filesProcessed\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">cacheEfficiency\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">content\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalPages\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averagePageSize\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">imageOptimizationRatio\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">brokenLinks\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">performance\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">coreWebVitals\u003C/span>: { \u003Cspan class=\"hljs-attr\">lcp\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">fid\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">cls\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n                \u003Cspan class=\"hljs-attr\">lighthouse\u003C/span>: { \u003Cspan class=\"hljs-attr\">performance\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">accessibility\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">bestPractices\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">seo\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> },\n                \u003Cspan class=\"hljs-attr\">bandwidthSavings\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n            }\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">alerts\u003C/span> = [];\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">historicalData\u003C/span> = [];\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">initialize\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Initializing performance dashboard...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Set up real-time monitoring\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">setupRealTimeMonitoring\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Set up periodic data collection\u003C/span>\n        \u003Cspan class=\"hljs-built_in\">setInterval\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">collectMetrics\u003C/span>(), \u003Cspan class=\"hljs-number\">60000\u003C/span>); \u003Cspan class=\"hljs-comment\">// Every minute\u003C/span>\n        \n        \u003Cspan class=\"hljs-comment\">// Set up historical data cleanup\u003C/span>\n        \u003Cspan class=\"hljs-built_in\">setInterval\u003C/span>(\u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">cleanupHistoricalData\u003C/span>(), \u003Cspan class=\"hljs-number\">3600000\u003C/span>); \u003Cspan class=\"hljs-comment\">// Every hour\u003C/span>\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Performance dashboard initialized&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">setupRealTimeMonitoring\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Integration with Google Analytics or similar\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-keyword\">typeof\u003C/span> \u003Cspan class=\"hljs-variable language_\">window\u003C/span> !== \u003Cspan class=\"hljs-string\">&#x27;undefined&#x27;\u003C/span>) {\n            \u003Cspan class=\"hljs-comment\">// Client-side monitoring\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">setupClientSideMonitoring\u003C/span>();\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-comment\">// Server-side monitoring\u003C/span>\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">setupServerSideMonitoring\u003C/span>();\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">setupClientSideMonitoring\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Core Web Vitals monitoring\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-string\">&#x27;PerformanceObserver&#x27;\u003C/span> \u003Cspan class=\"hljs-keyword\">in\u003C/span> \u003Cspan class=\"hljs-variable language_\">window\u003C/span>) {\n            \u003Cspan class=\"hljs-comment\">// Largest Contentful Paint\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">PerformanceObserver\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">list\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> entries = list.\u003Cspan class=\"hljs-title function_\">getEntries\u003C/span>();\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> lastEntry = entries[entries.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>];\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">recordMetric\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;lcp&#x27;\u003C/span>, lastEntry.\u003Cspan class=\"hljs-property\">startTime\u003C/span>);\n            }).\u003Cspan class=\"hljs-title function_\">observe\u003C/span>({ \u003Cspan class=\"hljs-attr\">entryTypes\u003C/span>: [\u003Cspan class=\"hljs-string\">&#x27;largest-contentful-paint&#x27;\u003C/span>] });\n            \n            \u003Cspan class=\"hljs-comment\">// First Input Delay\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">PerformanceObserver\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">list\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> entries = list.\u003Cspan class=\"hljs-title function_\">getEntries\u003C/span>();\n                entries.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">entry\u003C/span> =&gt;\u003C/span> {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">recordMetric\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fid&#x27;\u003C/span>, entry.\u003Cspan class=\"hljs-property\">processingStart\u003C/span> - entry.\u003Cspan class=\"hljs-property\">startTime\u003C/span>);\n                });\n            }).\u003Cspan class=\"hljs-title function_\">observe\u003C/span>({ \u003Cspan class=\"hljs-attr\">entryTypes\u003C/span>: [\u003Cspan class=\"hljs-string\">&#x27;first-input&#x27;\u003C/span>] });\n            \n            \u003Cspan class=\"hljs-comment\">// Cumulative Layout Shift\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">PerformanceObserver\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">list\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">let\u003C/span> clsValue = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> entries = list.\u003Cspan class=\"hljs-title function_\">getEntries\u003C/span>();\n                \n                entries.\u003Cspan class=\"hljs-title function_\">forEach\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">entry\u003C/span> =&gt;\u003C/span> {\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!entry.\u003Cspan class=\"hljs-property\">hadRecentInput\u003C/span>) {\n                        clsValue += entry.\u003Cspan class=\"hljs-property\">value\u003C/span>;\n                    }\n                });\n                \n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">recordMetric\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;cls&#x27;\u003C/span>, clsValue);\n            }).\u003Cspan class=\"hljs-title function_\">observe\u003C/span>({ \u003Cspan class=\"hljs-attr\">entryTypes\u003C/span>: [\u003Cspan class=\"hljs-string\">&#x27;layout-shift&#x27;\u003C/span>] });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Page load time monitoring\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">window\u003C/span>.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;load&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> loadTime = performance.\u003Cspan class=\"hljs-property\">timing\u003C/span>.\u003Cspan class=\"hljs-property\">loadEventEnd\u003C/span> - performance.\u003Cspan class=\"hljs-property\">timing\u003C/span>.\u003Cspan class=\"hljs-property\">navigationStart\u003C/span>;\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">recordMetric\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;pageLoadTime&#x27;\u003C/span>, loadTime);\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// Error monitoring\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">window\u003C/span>.\u003Cspan class=\"hljs-title function_\">addEventListener\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">event\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">recordError\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: event.\u003Cspan class=\"hljs-property\">message\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">filename\u003C/span>: event.\u003Cspan class=\"hljs-property\">filename\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">lineno\u003C/span>: event.\u003Cspan class=\"hljs-property\">lineno\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">timestamp\u003C/span>: \u003Cspan class=\"hljs-title class_\">Date\u003C/span>.\u003Cspan class=\"hljs-title function_\">now\u003C/span>()\n            });\n        });\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">setupServerSideMonitoring\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Server-side performance monitoring\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> express = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;express&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> app = \u003Cspan class=\"hljs-title function_\">express\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Request timing middleware\u003C/span>\n        app.\u003Cspan class=\"hljs-title function_\">use\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">req, res, next\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> start = process.\u003Cspan class=\"hljs-property\">hrtime\u003C/span>.\u003Cspan class=\"hljs-title function_\">bigint\u003C/span>();\n            \n            res.\u003Cspan class=\"hljs-title function_\">on\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;finish&#x27;\u003C/span>, \u003Cspan class=\"hljs-function\">() =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> duration = \u003Cspan class=\"hljs-title class_\">Number\u003C/span>(process.\u003Cspan class=\"hljs-property\">hrtime\u003C/span>.\u003Cspan class=\"hljs-title function_\">bigint\u003C/span>() - start) / \u003Cspan class=\"hljs-number\">1000000\u003C/span>; \u003Cspan class=\"hljs-comment\">// Convert to ms\u003C/span>\n                \n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">recordMetric\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;requestTime&#x27;\u003C/span>, duration);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (duration &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">alertThresholds\u003C/span>.\u003Cspan class=\"hljs-property\">pageLoadTime\u003C/span>) {\n                    \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createAlert\u003C/span>({\n                        \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;slow_response&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;warning&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">message\u003C/span>: \\\u003Cspan class=\"hljs-string\">`Slow response time: \\${duration}ms for \\${req.url}\\`,\n                        url: req.url,\n                        duration\n                    });\n                }\n            });\n            \n            next();\n        });\n    }\n    \n    recordMetric(type, value) {\n        const timestamp = Date.now();\n        \n        switch (type) {\n            case &#x27;lcp&#x27;:\n                this.metrics.performance.coreWebVitals.lcp = value;\n                if (value &gt; this.alertThresholds.coreWebVitals.lcp) {\n                    this.createAlert({\n                        type: &#x27;core_web_vitals&#x27;,\n                        severity: &#x27;warning&#x27;,\n                        message: \\`LCP threshold exceeded: \\${value}ms\\`,\n                        metric: &#x27;lcp&#x27;,\n                        value\n                    });\n                }\n                break;\n                \n            case &#x27;fid&#x27;:\n                this.metrics.performance.coreWebVitals.fid = value;\n                if (value &gt; this.alertThresholds.coreWebVitals.fid) {\n                    this.createAlert({\n                        type: &#x27;core_web_vitals&#x27;,\n                        severity: &#x27;warning&#x27;,\n                        message: \\`FID threshold exceeded: \\${value}ms\\`,\n                        metric: &#x27;fid&#x27;,\n                        value\n                    });\n                }\n                break;\n                \n            case &#x27;cls&#x27;:\n                this.metrics.performance.coreWebVitals.cls = value;\n                if (value &gt; this.alertThresholds.coreWebVitals.cls) {\n                    this.createAlert({\n                        type: &#x27;core_web_vitals&#x27;,\n                        severity: &#x27;warning&#x27;,\n                        message: \\`CLS threshold exceeded: \\${value}\\`,\n                        metric: &#x27;cls&#x27;,\n                        value\n                    });\n                }\n                break;\n                \n            case &#x27;pageLoadTime&#x27;:\n                this.updateAverageMetric(&#x27;avgLoadTime&#x27;, value);\n                break;\n                \n            case &#x27;requestTime&#x27;:\n                this.updateAverageMetric(&#x27;avgRequestTime&#x27;, value);\n                break;\n        }\n        \n        // Store in historical data\n        this.historicalData.push({\n            timestamp,\n            type,\n            value\n        });\n    }\n    \n    recordError(error) {\n        this.metrics.realTime.errorRate += 1;\n        \n        this.createAlert({\n            type: &#x27;javascript_error&#x27;,\n            severity: &#x27;error&#x27;,\n            message: error.message,\n            filename: error.filename,\n            lineno: error.lineno,\n            timestamp: error.timestamp\n        });\n    }\n    \n    updateAverageMetric(metricName, newValue) {\n        const currentValue = this.metrics.realTime[metricName] || 0;\n        const count = this.getMetricCount(metricName) || 1;\n        \n        this.metrics.realTime[metricName] = \n            (currentValue * (count - 1) + newValue) / count;\n    }\n    \n    getMetricCount(metricName) {\n        return this.historicalData.filter(d =&gt; \n            d.type === metricName.replace(&#x27;avg&#x27;, &#x27;&#x27;).toLowerCase()\n        ).length;\n    }\n    \n    createAlert(alertData) {\n        const alert = {\n            id: \\`alert_\\${Date.now()}_\\${Math.random().toString(36).substr(2, 9)}\\`,\n            timestamp: Date.now(),\n            acknowledged: false,\n            ...alertData\n        };\n        \n        this.alerts.push(alert);\n        \n        // Keep only last 100 alerts\n        if (this.alerts.length &gt; 100) {\n            this.alerts = this.alerts.slice(-100);\n        }\n        \n        // Send notification if configured\n        this.sendAlertNotification(alert);\n        \n        console.log(\\`[ALERT] \\${alert.severity.toUpperCase()}: \\${alert.message}\\`);\n    }\n    \n    async sendAlertNotification(alert) {\n        // Implementation would depend on your notification system\n        // Could be email, Slack, webhook, etc.\n        \n        if (alert.severity === &#x27;error&#x27;) {\n            // Send immediate notification for errors\n            console.log(&#x27;Sending immediate error notification:&#x27;, alert);\n        } else if (alert.severity === &#x27;warning&#x27;) {\n            // Batch warning notifications\n            console.log(&#x27;Queuing warning notification:&#x27;, alert);\n        }\n    }\n    \n    async collectMetrics() {\n        console.log(&#x27;Collecting performance metrics...&#x27;);\n        \n        try {\n            // Collect build metrics\n            if (this.metricsCollector) {\n                const buildMetrics = await this.metricsCollector.getBuildMetrics();\n                this.metrics.build = { ...this.metrics.build, ...buildMetrics };\n            }\n            \n            // Run Lighthouse audit periodically\n            if (Math.random() &lt; 0.1) { // 10% chance each collection cycle\n                await this.runLighthouseAudit();\n            }\n            \n            // Calculate performance scores\n            await this.calculatePerformanceScores();\n            \n        } catch (error) {\n            console.error(&#x27;Error collecting metrics:&#x27;, error);\n        }\n    }\n    \n    async runLighthouseAudit() {\n        try {\n            const lighthouse = require(&#x27;lighthouse&#x27;);\n            const chromeLauncher = require(&#x27;chrome-launcher&#x27;);\n            \n            const chrome = await chromeLauncher.launch({\n                chromeFlags: [&#x27;--headless&#x27;, &#x27;--no-sandbox&#x27;]\n            });\n            \n            const options = {\n                logLevel: &#x27;info&#x27;,\n                output: &#x27;json&#x27;,\n                onlyCategories: [&#x27;performance&#x27;, &#x27;accessibility&#x27;, &#x27;best-practices&#x27;, &#x27;seo&#x27;],\n                port: chrome.port\n            };\n            \n            const runnerResult = await lighthouse(&#x27;http://localhost:3000&#x27;, options);\n            await chrome.kill();\n            \n            const scores = runnerResult.lhr.categories;\n            \n            this.metrics.performance.lighthouse = {\n                performance: Math.round(scores.performance.score * 100),\n                accessibility: Math.round(scores.accessibility.score * 100),\n                bestPractices: Math.round(scores[&#x27;best-practices&#x27;].score * 100),\n                seo: Math.round(scores.seo.score * 100)\n            };\n            \n            // Create alerts for poor scores\n            Object.entries(this.metrics.performance.lighthouse).forEach(([category, score]) =&gt; {\n                if (score &lt; 80) {\n                    this.createAlert({\n                        type: &#x27;lighthouse_score&#x27;,\n                        severity: score &lt; 60 ? &#x27;error&#x27; : &#x27;warning&#x27;,\n                        message: \\`Low \\${category} score: \\${score}/100\\`,\n                        category,\n                        score\n                    });\n                }\n            });\n            \n        } catch (error) {\n            console.error(&#x27;Lighthouse audit failed:&#x27;, error);\n        }\n    }\n    \n    async calculatePerformanceScores() {\n        // Calculate overall performance score\n        const coreVitals = this.metrics.performance.coreWebVitals;\n        const lighthouse = this.metrics.performance.lighthouse;\n        \n        let performanceScore = 0;\n        let scoringFactors = 0;\n        \n        // Core Web Vitals contribution (40%)\n        if (coreVitals.lcp &gt; 0) {\n            const lcpScore = Math.max(0, 100 - (coreVitals.lcp - 1000) / 25);\n            performanceScore += lcpScore * 0.15;\n            scoringFactors += 0.15;\n        }\n        \n        if (coreVitals.fid &gt; 0) {\n            const fidScore = Math.max(0, 100 - coreVitals.fid);\n            performanceScore += fidScore * 0.1;\n            scoringFactors += 0.1;\n        }\n        \n        if (coreVitals.cls &gt; 0) {\n            const clsScore = Math.max(0, 100 - coreVitals.cls * 1000);\n            performanceScore += clsScore * 0.15;\n            scoringFactors += 0.15;\n        }\n        \n        // Lighthouse contribution (60%)\n        if (lighthouse.performance &gt; 0) {\n            performanceScore += lighthouse.performance * 0.6;\n            scoringFactors += 0.6;\n        }\n        \n        this.metrics.performance.overallScore = scoringFactors &gt; 0 ? \n            Math.round(performanceScore / scoringFactors) : 0;\n    }\n    \n    cleanupHistoricalData() {\n        const twentyFourHoursAgo = Date.now() - 24 * 60 * 60 * 1000;\n        \n        this.historicalData = this.historicalData.filter(\n            data =&gt; data.timestamp &gt; twentyFourHoursAgo\n        );\n        \n        console.log(\\`Cleaned up historical data, \\${this.historicalData.length} entries remaining\\`);\n    }\n    \n    generateDashboardData() {\n        const now = Date.now();\n        const oneHourAgo = now - 60 * 60 * 1000;\n        \n        // Get recent data for trends\n        const recentData = this.historicalData.filter(\n            data =&gt; data.timestamp &gt; oneHourAgo\n        );\n        \n        return {\n            timestamp: now,\n            metrics: this.metrics,\n            alerts: this.alerts.filter(alert =&gt; !alert.acknowledged),\n            trends: this.calculateTrends(recentData),\n            recommendations: this.generateRecommendations()\n        };\n    }\n    \n    calculateTrends(recentData) {\n        const trends = {};\n        const metricTypes = [...new Set(recentData.map(d =&gt; d.type))];\n        \n        metricTypes.forEach(type =&gt; {\n            const typeData = recentData\n                .filter(d =&gt; d.type === type)\n                .sort((a, b) =&gt; a.timestamp - b.timestamp);\n            \n            if (typeData.length &gt;= 2) {\n                const latest = typeData[typeData.length - 1].value;\n                const earlier = typeData[0].value;\n                const change = ((latest - earlier) / earlier) * 100;\n                \n                trends[type] = {\n                    current: latest,\n                    change: Math.round(change * 100) / 100,\n                    direction: change &gt; 0 ? &#x27;up&#x27; : change &lt; 0 ? &#x27;down&#x27; : &#x27;stable&#x27;\n                };\n            }\n        });\n        \n        return trends;\n    }\n    \n    generateRecommendations() {\n        const recommendations = [];\n        const metrics = this.metrics;\n        \n        // Performance recommendations\n        if (metrics.performance.coreWebVitals.lcp &gt; 2500) {\n            recommendations.push({\n                type: &#x27;performance&#x27;,\n                priority: &#x27;high&#x27;,\n                title: &#x27;Improve Largest Contentful Paint&#x27;,\n                description: &#x27;LCP is above 2.5 seconds, affecting user experience&#x27;,\n                actions: [\n                    &#x27;Optimize images and implement lazy loading&#x27;,\n                    &#x27;Minimize render-blocking resources&#x27;,\n                    &#x27;Use efficient caching strategies&#x27;\n                ]\n            });\n        }\n        \n        if (metrics.performance.lighthouse.performance &lt; 80) {\n            recommendations.push({\n                type: &#x27;lighthouse&#x27;,\n                priority: &#x27;medium&#x27;,\n                title: &#x27;Improve Lighthouse Performance Score&#x27;,\n                description: \\`Current performance score is \\${metrics.performance.lighthouse.performance}/100\\`,\n                actions: [\n                    &#x27;Minimize and compress JavaScript and CSS&#x27;,\n                    &#x27;Optimize image delivery and formats&#x27;,\n                    &#x27;Implement effective caching headers&#x27;\n                ]\n            });\n        }\n        \n        // Build performance recommendations\n        if (metrics.build.cacheEfficiency &lt; 0.6) {\n            recommendations.push({\n                type: &#x27;build&#x27;,\n                priority: &#x27;medium&#x27;,\n                title: &#x27;Improve Build Cache Efficiency&#x27;,\n                description: &#x27;Cache hit rate is below 60%, slowing down builds&#x27;,\n                actions: [\n                    &#x27;Review cache invalidation strategies&#x27;,\n                    &#x27;Implement more granular caching&#x27;,\n                    &#x27;Consider dependency-based cache keys&#x27;\n                ]\n            });\n        }\n        \n        return recommendations;\n    }\n    \n    acknowledgeAlert(alertId) {\n        const alert = this.alerts.find(a =&gt; a.id === alertId);\n        if (alert) {\n            alert.acknowledged = true;\n            alert.acknowledgedAt = Date.now();\n            console.log(\\`Alert acknowledged: \\${alertId}\\`);\n        }\n    }\n    \n    exportMetrics(format = &#x27;json&#x27;) {\n        const data = this.generateDashboardData();\n        \n        switch (format) {\n            case &#x27;json&#x27;:\n                return JSON.stringify(data, null, 2);\n            case &#x27;csv&#x27;:\n                return this.convertToCSV(data);\n            default:\n                return data;\n        }\n    }\n    \n    convertToCSV(data) {\n        // Simple CSV conversion for metrics\n        const rows = [];\n        rows.push(&#x27;timestamp,metric,value&#x27;);\n        \n        this.historicalData.forEach(entry =&gt; {\n            rows.push(\\`\\${entry.timestamp},\\${entry.type},\\${entry.value}\\`);\n        });\n        \n        return rows.join(&#x27;\\\\n&#x27;);\n    }\n}\n\nmodule.exports = MarkdownPerformanceDashboard;\u003C/span>\n\u003C/code>\u003C/pre>\u003Ch2 id=\"troubleshooting-common-performance-issues\">Troubleshooting Common Performance Issues\u003C/h2>\n\u003Ch3 id=\"memory-optimization\">Memory Optimization\u003C/h3>\n\u003Cp>\u003Cstrong>Problem\u003C/strong>: High memory usage during large content builds\u003C/p>\n\u003Cp>\u003Cstrong>Solutions\u003C/strong>:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// Memory optimization techniques\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">MemoryOptimizedProcessor\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">processedCount\u003C/span> = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryThreshold\u003C/span> = \u003Cspan class=\"hljs-number\">500\u003C/span> * \u003Cspan class=\"hljs-number\">1024\u003C/span> * \u003Cspan class=\"hljs-number\">1024\u003C/span>; \u003Cspan class=\"hljs-comment\">// 500MB\u003C/span>\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">processFiles\u003C/span>(\u003Cspan class=\"hljs-params\">files\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> batches = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">createMemoryAwareBatches\u003C/span>(files);\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> batch \u003Cspan class=\"hljs-keyword\">of\u003C/span> batches) {\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processBatch\u003C/span>(batch);\n            \n            \u003Cspan class=\"hljs-comment\">// Force garbage collection if available\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">global\u003C/span>.\u003Cspan class=\"hljs-property\">gc\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">global\u003C/span>.\u003Cspan class=\"hljs-title function_\">gc\u003C/span>();\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Monitor memory usage\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> memUsage = process.\u003Cspan class=\"hljs-title function_\">memoryUsage\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (memUsage.\u003Cspan class=\"hljs-property\">heapUsed\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">memoryThreshold\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;High memory usage detected, clearing caches&#x27;\u003C/span>);\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">clearTemporaryCaches\u003C/span>();\n            }\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">createMemoryAwareBatches\u003C/span>(\u003Cspan class=\"hljs-params\">files\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Estimate memory usage per file and create appropriate batches\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> files.\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">batches, file, index\u003C/span>) =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> batchIndex = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">floor\u003C/span>(index / \u003Cspan class=\"hljs-number\">20\u003C/span>); \u003Cspan class=\"hljs-comment\">// Max 20 files per batch\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!batches[batchIndex]) batches[batchIndex] = [];\n            batches[batchIndex].\u003Cspan class=\"hljs-title function_\">push\u003C/span>(file);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> batches;\n        }, []);\n    }\n}\n\u003C/code>\u003C/pre>\u003Ch3 id=\"build-speed-optimization\">Build Speed Optimization\u003C/h3>\n\u003Cp>\u003Cstrong>Problem\u003C/strong>: Slow build times for large documentation sites\u003C/p>\n\u003Cp>\u003Cstrong>Solutions\u003C/strong>:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// Build speed optimization strategies\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">BuildSpeedOptimizer\u003C/span> {\n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeBuildProcess\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// 1. Implement smart dependency tracking\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> changedFiles = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">detectChangedFiles\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> affectedFiles = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateDependencyImpact\u003C/span>(changedFiles);\n        \n        \u003Cspan class=\"hljs-comment\">// 2. Use parallel processing\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> processor = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">ParallelProcessor\u003C/span>({\n            \u003Cspan class=\"hljs-attr\">maxWorkers\u003C/span>: os.\u003Cspan class=\"hljs-title function_\">cpus\u003C/span>().\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">chunkSize\u003C/span>: \u003Cspan class=\"hljs-number\">10\u003C/span>\n        });\n        \n        \u003Cspan class=\"hljs-comment\">// 3. Optimize asset processing\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">preOptimizeAssets\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// 4. Use streaming for large files\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">streamProcessFiles\u003C/span>(affectedFiles);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">detectChangedFiles\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Git-based change detection\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> { execSync } = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;child_process&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> changedFiles = \u003Cspan class=\"hljs-title function_\">execSync\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;git diff --name-only HEAD~1 HEAD&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">toString\u003C/span>()\n            .\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">file\u003C/span> =&gt;\u003C/span> file.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>));\n            \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> changedFiles;\n    }\n}\n\u003C/code>\u003C/pre>\u003Ch2 id=\"conclusion\">Conclusion\u003C/h2>\n\u003Cp>Advanced Markdown performance optimization and best practices represent a sophisticated approach to building high-performance documentation systems that deliver exceptional user experiences while maintaining scalability and developer productivity. Through intelligent caching strategies, asset optimization techniques, and comprehensive performance monitoring, technical teams can create lightning-fast Markdown-based platforms that handle massive content volumes efficiently while preserving content quality and editorial workflows.\u003C/p>\n\u003Cp>The key to successful performance optimization lies in implementing systematic measurement, continuous monitoring, and proactive optimization strategies that address both build-time and runtime performance characteristics. Whether you&#39;re building technical documentation, knowledge bases, or content management systems, the techniques covered in this guide provide the foundation for creating performant, scalable Markdown systems that delight users and maintainers alike.\u003C/p>\n\u003Cp>Remember to implement performance monitoring from the beginning of your project, establish performance budgets that guide development decisions, and continuously analyze real-world usage patterns to optimize for actual user behavior. With proper implementation of advanced performance optimization techniques, your Markdown-based content systems can achieve exceptional speed and reliability while maintaining the simplicity and maintainability that makes Markdown such an effective content creation format.\u003C/p>\n",[15,19,22,25,28,31,34,37],{"id":16,"text":17,"level":18},"why-master-markdown-performance-optimization","Why Master Markdown Performance Optimization?",2,{"id":20,"text":21,"level":18},"foundation-performance-principles","Foundation Performance Principles",{"id":23,"text":24,"level":18},"asset-optimization-and-delivery","Asset Optimization and Delivery",{"id":26,"text":27,"level":18},"build-process-optimization","Build Process Optimization",{"id":29,"text":30,"level":18},"performance-integration-with-documentation-systems","Performance Integration with Documentation Systems",{"id":32,"text":33,"level":18},"advanced-performance-monitoring-and-analytics","Advanced Performance Monitoring and Analytics",{"id":35,"text":36,"level":18},"troubleshooting-common-performance-issues","Troubleshooting Common Performance Issues",{"id":38,"text":39,"level":18},"conclusion","Conclusion",[],[42,50,58],{"slug":43,"title":44,"description":45,"excerpt":46,"date":47,"category":9,"author":10,"keywords":48,"readingMinutes":49},"markdown-performance-optimization-rendering-speed-guide","Markdown Performance Optimization and Rendering Speed: Complete Guide for High-Performance Documentation Systems","Master Markdown performance optimization techniques for faster rendering, efficient processing, and scalable documentation systems. Learn caching strategies, parser optimization, and performance monitoring for large-scale content management.","Advanced Markdown performance optimization enables high-speed rendering and efficient processing for large-scale documentation systems that handle thousands of documents with complex content…","2025-09-30","markdown performance, markdown rendering speed, markdown optimization, markdown parser performance, documentation performance, markdown caching, static site performance, markdown processing speed",25,{"slug":51,"title":52,"description":53,"excerpt":54,"date":55,"category":9,"author":10,"keywords":56,"readingMinutes":57},"markdown-table-performance-optimization-complete-guide","Markdown Table Performance Optimization and Responsive Design: Complete Guide for High-Performance Documentation and Data Display","Master advanced Markdown table performance optimization techniques for large datasets, responsive design patterns, and mobile-friendly data presentation. Learn table virtualization, lazy loading, and adaptive design strategies for documentation systems.","Advanced Markdown table performance optimization and responsive design techniques enable sophisticated data presentation systems that maintain performance across large datasets while providing…","2026-01-03","markdown table performance, responsive markdown tables, table optimization, large dataset tables, mobile markdown tables, table virtualization, adaptive table design, data presentation",18,{"slug":59,"title":60,"description":61,"excerpt":62,"date":63,"category":9,"author":10,"keywords":64,"readingMinutes":65},"markdown-performance-optimization-complete-guide","Markdown Performance Optimization: Complete Guide for High-Volume Content Processing and Rendering Efficiency","Master advanced Markdown performance optimization techniques for large-scale content processing, rendering efficiency, and high-volume documentation systems. Learn caching strategies, parsing optimization, and performance monitoring for Markdown workflows.","Advanced Markdown performance optimization techniques enable high-volume content processing systems that deliver exceptional rendering speeds, efficient memory usage, and scalable processing…","2025-10-28","markdown performance optimization, markdown parsing performance, markdown rendering speed, markdown content caching, large scale markdown, markdown processing efficiency, markdown performance monitoring, markdown optimization techniques",22,1792184945108]