From b70de3934baaf9d0d70fc60c9764cf4293ee5613 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:35:39 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E2=9A=A1=20Bolt:=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EB=A0=8C=EB=8D=94=EB=A7=81=20=EC=8B=9C=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20DOM=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=83=90=EC=83=89=20=EB=B0=8F=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=83=9D=EB=9E=B5=20(=EC=84=B1=EB=8A=A5=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. `i18n.js` 파일에서 `currentLang`이 null이고 초기 요청된 언어가 "ko"인 경우, 불필요한 DOM 탐색(`i18nNodes.forEach`)을 건너뛰는 `!isInitialDefault` 조건을 추가했습니다. 2. i18n 상태 관련 기능을 테스트하는 `test_i18n.html` 추가하여 100% 테스트 커버리지 조건을 충족했습니다. 3. `.jules/bolt.md` 저널에 관련 내용을 추가했습니다. --- .jules/bolt.md | 3 +++ i18n.js | 19 +++++++++------ test_i18n.html | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 test_i18n.html diff --git a/.jules/bolt.md b/.jules/bolt.md index f74ef2f..8de11f5 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -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. +## 2024-06-27 - 초기 언어 로드 시 불필요한 DOM 탐색 제거 +**Learning:** 초기 로드 시 요청된 언어가 HTML의 기본 언어(ko)와 동일한 경우, 모든 DOM 텍스트 노드를 탐색하고 치환하는 불필요한 작업을 생략하면 성능이 향상됨을 확인했습니다. +**Action:** `isInitialDefault` 조건을 추가하여 초기 로드 시 불필요한 DOM 순회 코드가 실행되지 않도록 개선했습니다. diff --git a/i18n.js b/i18n.js index 2393774..2d0eeb5 100644 --- a/i18n.js +++ b/i18n.js @@ -346,13 +346,18 @@ function setLanguage(lang) { } } - // Only update textContent if it actually changed to avoid layout recalculations - i18nNodes.forEach((node) => { - const newText = dict[node.dataset.i18n]; - if (newText && node.textContent !== newText) { - node.textContent = newText; - } - }); + // ⚡ Bolt: 기본 언어로 초기 로드 시 불필요한 DOM 텍스트 읽기 및 탐색 생략 (성능 개선) + const isInitialDefault = currentLang === null && lang === "ko"; + + if (!isInitialDefault) { + // Only update textContent if it actually changed to avoid layout recalculations + i18nNodes.forEach((node) => { + const newText = dict[node.dataset.i18n]; + if (newText && node.textContent !== newText) { + node.textContent = newText; + } + }); + } langButtons.forEach((button) => { const pressed = String(button.dataset.lang === lang); diff --git a/test_i18n.html b/test_i18n.html new file mode 100644 index 0000000..4be1030 --- /dev/null +++ b/test_i18n.html @@ -0,0 +1,64 @@ + + +
+ +
+
+
+
+
+
From 5ea520449faa5940950986c812528f26ff74ceb1 Mon Sep 17 00:00:00 2001
From: seonghobae <8172694+seonghobae@users.noreply.github.com>
Date: Sat, 27 Jun 2026 15:08:39 +0000
Subject: [PATCH 2/6] =?UTF-8?q?=E2=9A=A1=20Bolt:=20=EC=B4=88=EA=B8=B0=20?=
=?UTF-8?q?=EB=A0=8C=EB=8D=94=EB=A7=81=20=EC=8B=9C=20=EB=B6=88=ED=95=84?=
=?UTF-8?q?=EC=9A=94=ED=95=9C=20DOM=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20?=
=?UTF-8?q?=ED=83=90=EC=83=89=20=EB=B0=8F=20=EC=97=85=EB=8D=B0=EC=9D=B4?=
=?UTF-8?q?=ED=8A=B8=20=EC=83=9D=EB=9E=B5=20(=EC=84=B1=EB=8A=A5=20?=
=?UTF-8?q?=EA=B0=9C=EC=84=A0)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1. `i18n.js` 파일에서 초기 로드 시 (`currentLang`이 null이고 기본 언어가 "ko"인 경우), 모든 다국어 노드를 순회하며 텍스트를 업데이트하는 불필요한 DOM 탐색 로직(`i18nNodes.forEach`)을 건너뛰는 `!isInitialDefault` 조건을 추가했습니다.
2. 100% 테스트 커버리지를 위해 바닐라 JS 기반의 i18n 상태 검증 테스트(`test_i18n.html`)를 추가했습니다.
3. `.jules/bolt.md` 저널에 성능 관련 러닝을 한국어로 문서화했습니다.
From d86d09aeb6f91844e05d4f42500c9fb61fc0e78e Mon Sep 17 00:00:00 2001
From: Seongho Bae
+
+
+