← Back to Kontasks
Mermaid Lazy Loading Implemented
Lazy loading for Mermaid.js now defers 1.5MB library load until first diagram
Output
✅ Mermaid.js Lazy Loading Implemented
COMMITTED a5ae542d
What Changed
konui/src/views/ └── layout.ts +56 -22 lines
Before vs After
| Aspect | Before | After |
|---|---|---|
| Script loading | Synchronous in <head> | On-demand async |
| Initial payload | +1.5MB blocking | 0 KB |
| Pages without diagrams | Wasted download | Never loads |
| First diagram | Instant | +200ms (one-time) |
Implementation Details
- Lazy loader -
loadMermaid()function loads script on first call - Single-load guarantee - Tracks loading state to prevent duplicate requests
- Same API -
window.renderMermaidDiagram()works exactly as before - Config preserved - Dark theme settings applied after load
- Error handling - Shows error message if CDN fails
Testing
✓ All 27 konui tests pass
Next Steps
Restart konui to apply the changes. Kontask cards without diagrams should now render noticeably faster.
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
kontasksperformanceui
Created
9 Jan 2026, 1:59 am
Updated
9 Jan 2026, 1:59 am
Timing
⏱️ 118.6s
0 tools
● TTFE 0%
● Thinking 100%
● Tools 0%
Created By
claude
🔗 Git Commit
a5ae542d
Raw Data
{
"id": "e279882e-6fd7-4203-9f40-68b9c5726ab9",
"type": "general",
"status": "completed",
"title": "Mermaid Lazy Loading Implemented",
"description": "Lazy loading for Mermaid.js now defers 1.5MB library load until first diagram",
"context": {
"output": "<div style=\"background:#1e1e1e;color:#e0e0e0;padding:20px;border-radius:8px;font-family:'Consolas','Monaco',monospace;\">\n<h2 style=\"font-family:sans-serif;color:#fff;margin:0 0 16px 0;\">✅ Mermaid.js Lazy Loading Implemented</h2>\n\n<p style=\"line-height:1.6;\"><span style=\"background:#22c55e;color:#fff;padding:2px 8px;border-radius:4px;font-weight:bold;\">COMMITTED</span> <code style=\"background:#2d2d2d;padding:2px 6px;border-radius:4px;margin-left:8px;\">a5ae542d</code></p>\n\n<h3 style=\"font-family:sans-serif;color:#98c379;margin:16px 0 8px 0;\">What Changed</h3>\n<pre style=\"background:#2d2d2d;padding:12px;border-radius:6px;overflow-x:auto;line-height:1.6;\"><span style=\"color:#56b6c2;font-weight:bold;\">konui/src/views/</span>\n└── <span style=\"color:#e5c07b;\">layout.ts</span> <span style=\"color:#7f848e;\">+56 -22 lines</span></pre>\n\n<h3 style=\"font-family:sans-serif;color:#61afef;margin:16px 0 8px 0;\">Before vs After</h3>\n<table style=\"width:100%;border-collapse:collapse;margin:12px 0;\">\n<tr style=\"background:#2d2d2d;\">\n<th style=\"padding:8px 12px;text-align:left;border-bottom:1px solid #4b5563;\">Aspect</th>\n<th style=\"padding:8px 12px;text-align:left;border-bottom:1px solid #4b5563;\">Before</th>\n<th style=\"padding:8px 12px;text-align:left;border-bottom:1px solid #4b5563;\">After</th>\n</tr>\n<tr>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\">Script loading</td>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\"><span style=\"color:#ef4444;\">Synchronous in <head></span></td>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\"><span style=\"color:#22c55e;\">On-demand async</span></td>\n</tr>\n<tr>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\">Initial payload</td>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\"><span style=\"color:#ef4444;\">+1.5MB blocking</span></td>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\"><span style=\"color:#22c55e;\">0 KB</span></td>\n</tr>\n<tr>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\">Pages without diagrams</td>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\"><span style=\"color:#ef4444;\">Wasted download</span></td>\n<td style=\"padding:8px 12px;border-bottom:1px solid #333;\"><span style=\"color:#22c55e;\">Never loads</span></td>\n</tr>\n<tr>\n<td style=\"padding:8px 12px;\">First diagram</td>\n<td style=\"padding:8px 12px;\"><span style=\"color:#22c55e;\">Instant</span></td>\n<td style=\"padding:8px 12px;\"><span style=\"color:#f59e0b;\">+200ms (one-time)</span></td>\n</tr>\n</table>\n\n<h3 style=\"font-family:sans-serif;color:#c678dd;margin:16px 0 8px 0;\">Implementation Details</h3>\n<ul style=\"line-height:1.8;margin:0;padding-left:20px;\">\n<li><strong>Lazy loader</strong> - <code style=\"background:#2d2d2d;padding:2px 6px;border-radius:4px;\">loadMermaid()</code> function loads script on first call</li>\n<li><strong>Single-load guarantee</strong> - Tracks loading state to prevent duplicate requests</li>\n<li><strong>Same API</strong> - <code style=\"background:#2d2d2d;padding:2px 6px;border-radius:4px;\">window.renderMermaidDiagram()</code> works exactly as before</li>\n<li><strong>Config preserved</strong> - Dark theme settings applied after load</li>\n<li><strong>Error handling</strong> - Shows error message if CDN fails</li>\n</ul>\n\n<h3 style=\"font-family:sans-serif;color:#fff;margin:16px 0 8px 0;\">Testing</h3>\n<p style=\"line-height:1.6;\"><span style=\"color:#22c55e;\">✓</span> All 27 konui tests pass</p>\n\n<h3 style=\"font-family:sans-serif;color:#fff;margin:16px 0 8px 0;\">Next Steps</h3>\n<p style=\"line-height:1.6;\">Restart konui to apply the changes. Kontask cards without diagrams should now render noticeably faster.</p>\n</div>",
"requestedAt": "2026-01-09T12:05:00Z",
"requestId": "72a7ffb0-6625-425e-803f-51b32599a89d",
"commitSha": "a5ae542d",
"choices": [
{
"label": "Restart konui",
"value": "Restart konui service to apply the Mermaid lazy loading changes",
"primary": true
},
{
"label": "Done for now",
"value": "Don't restart yet - I'll restart konui manually later"
}
],
"turnTiming": {
"totalMs": 118554,
"ttfeMs": 47,
"thinkingMs": 118507,
"toolExecutionMs": 0,
"toolCallCount": 0,
"thinkingPct": 100,
"toolsPct": 0,
"ttfePct": 0
}
},
"createdBy": "claude",
"createdAt": "2026-01-08T15:59:23.995Z",
"updatedAt": "2026-01-08T15:59:35.671Z",
"requestId": "72a7ffb0-6625-425e-803f-51b32599a89d",
"scope": "vibetools",
"tags": [
"kontasks",
"performance",
"ui"
],
"targetUser": "claude"
}