diff --git a/desktop-app/resources/index.html b/desktop-app/resources/index.html index e1ef35a5..e2d2ee0a 100644 --- a/desktop-app/resources/index.html +++ b/desktop-app/resources/index.html @@ -16,10 +16,8 @@ Markdown Viewer - - - - + + @@ -856,6 +854,175 @@ + + diff --git a/desktop-app/resources/js/script.js b/desktop-app/resources/js/script.js index 6c58cc47..3ef4f3db 100644 --- a/desktop-app/resources/js/script.js +++ b/desktop-app/resources/js/script.js @@ -864,18 +864,13 @@ document.addEventListener("DOMContentLoaded", function () { .replace(/"/g, '"'); } - // PERF-012: Default template loaded from external file to reduce bundle size - let sampleMarkdown = '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; - fetch('sample.md').then(function(r) { return r.text(); }).then(function(text) { - sampleMarkdown = text; - // Only apply if editor still has the simple fallback or is empty - if (!markdownEditor.value || markdownEditor.value === '# Welcome to Markdown Viewer\n\nStart typing your markdown here...') { - markdownEditor.value = sampleMarkdown; - renderMarkdown(); - } - }).catch(function() { /* Use inline fallback */ }); + // PERF-012: Inlined default template to eliminate network request, FOUC, and layout shifts + const defaultMarkdownTemplate = document.getElementById('default-markdown'); + const sampleMarkdown = defaultMarkdownTemplate ? defaultMarkdownTemplate.textContent.trim() : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; - markdownEditor.value = sampleMarkdown; + if (!markdownEditor.value) { + markdownEditor.value = sampleMarkdown; + } // ======================================== // DOCUMENT TABS & SESSION MANAGEMENT diff --git a/index.html b/index.html index ae79be0c..0967da9d 100644 --- a/index.html +++ b/index.html @@ -78,10 +78,8 @@ Markdown Viewer - - - - + + @@ -915,6 +913,175 @@ + + diff --git a/script.js b/script.js index 6c58cc47..3ef4f3db 100644 --- a/script.js +++ b/script.js @@ -864,18 +864,13 @@ document.addEventListener("DOMContentLoaded", function () { .replace(/"/g, '"'); } - // PERF-012: Default template loaded from external file to reduce bundle size - let sampleMarkdown = '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; - fetch('sample.md').then(function(r) { return r.text(); }).then(function(text) { - sampleMarkdown = text; - // Only apply if editor still has the simple fallback or is empty - if (!markdownEditor.value || markdownEditor.value === '# Welcome to Markdown Viewer\n\nStart typing your markdown here...') { - markdownEditor.value = sampleMarkdown; - renderMarkdown(); - } - }).catch(function() { /* Use inline fallback */ }); + // PERF-012: Inlined default template to eliminate network request, FOUC, and layout shifts + const defaultMarkdownTemplate = document.getElementById('default-markdown'); + const sampleMarkdown = defaultMarkdownTemplate ? defaultMarkdownTemplate.textContent.trim() : '# Welcome to Markdown Viewer\n\nStart typing your markdown here...'; - markdownEditor.value = sampleMarkdown; + if (!markdownEditor.value) { + markdownEditor.value = sampleMarkdown; + } // ======================================== // DOCUMENT TABS & SESSION MANAGEMENT