Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2024-06-20 - Unnecessary initial DOM updates for default language
**Learning:** The simple static i18n implementation runs `node.textContent = dict[node.dataset.i18n]` for every translatable node on the initial script load, even when the HTML is already written in the target language (Korean). This creates unnecessary layout/paint operations and blocking time on the main thread for elements that don't need text changes.
**Action:** Always check if the current value matches the desired value before updating the DOM (`node.textContent !== newText`), and add early exits when setting state to the same value to avoid redundant DOM traversal and writes.
## 2026-06-22 - Prevent redundant DOM queries on initial language set
**Learning:** The simple static i18n implementation was scanning the entire document to set translations even when the pre-rendered document language matched the user's preferred language. This happened because `currentLang` was initially `null`, causing the early return `if (currentLang === lang) return;` to fail on the initial page load.
**Action:** Always initialize language state variables using existing document attributes (`document.documentElement.lang`) if available, to ensure early-return checks correctly skip redundant work when the page is already in the target state.
2 changes: 1 addition & 1 deletion i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ let langButtons = null;
let metaDesc = null;
let ogDesc = null;
let footerLogo = null;
let currentLang = null;
let currentLang = document.documentElement.lang || "ko";

function setLanguage(lang) {
if (currentLang === lang) return; // Skip if already in the requested language
Expand Down
Loading