-
Notifications
You must be signed in to change notification settings - Fork 0
⚡ Bolt: 초기 렌더링 시 불필요한 DOM 탐색 제거 (성능 개선) #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
github-actions
merged 7 commits into
main
from
bolt-i18n-performance-fix-17186841747068778712
Jul 1, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b70de39
⚡ Bolt: 초기 렌더링 시 불필요한 DOM 텍스트 탐색 및 업데이트 생략 (성능 개선)
seonghobae 5ea5204
⚡ Bolt: 초기 렌더링 시 불필요한 DOM 텍스트 탐색 및 업데이트 생략 (성능 개선)
seonghobae d86d09a
Address i18n review feedback
seonghobae 456fd86
Rerun review after thread resolution
seonghobae 6450365
Rerun required workflows after ruleset repair
seonghobae b46aafa
⚡ Bolt: 초기 렌더링 시 불필요한 DOM 탐색 방지 및 CI 수정
seonghobae b901e0c
Merge branch 'main' into bolt-i18n-performance-fix-17186841747068778712
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
| ## 2024-06-27 - 초기 언어 로드 시 불필요한 DOM 탐색 제거 | ||
| **Learning:** 초기 로드 시 요청된 언어가 HTML의 기본 언어(ko)와 동일한 경우, 모든 DOM 텍스트 노드를 탐색하고 치환하는 불필요한 작업을 생략하면 성능이 향상됨을 확인했습니다. | ||
| **Action:** `isInitialDefault` 조건을 추가하여 초기 로드 시 불필요한 DOM 순회 코드가 실행되지 않도록 개선했습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # CHANGELOG | ||
|
|
||
| ## [Unreleased] | ||
| - **성능 개선**: `i18n.js`에서 초기 로드 시 기본 언어가 한국어(ko)인 경우 불필요한 DOM 순회 및 텍스트 업데이트를 생략하도록 개선했습니다. | ||
| - **테스트 추가**: 다국어 처리 로직의 무결성을 검증하기 위해 `test_i18n.html` 테스트 파일을 추가했습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="ko"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>i18n Test</title> | ||
| <meta name="description" content="test"> | ||
| <meta property="og:description" content="test"> | ||
| </head> | ||
| <body> | ||
| <div data-i18n="hero.title">맥락지혜 연구실</div> | ||
| <button type="button" data-lang="ko" aria-pressed="true">KO</button> | ||
| <button type="button" data-lang="en" aria-pressed="false">EN</button> | ||
| <img id="footer-logo" src="assets/context-wisdom-lab-logo.svg" alt="맥락지혜 연구실 · Contextual Wisdom Lab"> | ||
| <script> | ||
| // Mock for global storage and initial test state | ||
| window.localStorageMock = { | ||
| getItem: function() { return null; }, | ||
| setItem: function() {} | ||
| }; | ||
| Object.defineProperty(window, 'localStorage', { value: window.localStorageMock }); | ||
| </script> | ||
| <script src="i18n.js"></script> | ||
| <script> | ||
| // Simple test harness | ||
| let testsPassed = 0; | ||
| let testsTotal = 0; | ||
|
|
||
| function assertEqual(actual, expected, testName) { | ||
| testsTotal++; | ||
| if (actual === expected) { | ||
| testsPassed++; | ||
| console.log(`[PASS] ${testName}`); | ||
| } else { | ||
| console.error(`[FAIL] ${testName} - Expected '${expected}', got '${actual}'`); | ||
| } | ||
| } | ||
|
|
||
| requestAnimationFrame(() => { | ||
| console.log("Running tests..."); | ||
|
|
||
| assertEqual(currentLang, "ko", "Initial language should be 'ko'"); | ||
|
|
||
| // Test 2: Switch to EN updates nodes correctly | ||
| setLanguage("en"); | ||
| assertEqual(currentLang, "en", "Language should be 'en' after setting"); | ||
| const titleNode = document.querySelector('[data-i18n="hero.title"]'); | ||
| assertEqual(titleNode.textContent, "Contextual Wisdom Lab", "Title text should change to English"); | ||
|
|
||
| // Test 3: Switch back to KO updates nodes correctly | ||
| setLanguage("ko"); | ||
| assertEqual(currentLang, "ko", "Language should be 'ko' after setting back"); | ||
| assertEqual(titleNode.textContent, "맥락지혜 연구실", "Title text back to Korean"); | ||
|
|
||
| console.log(`Test Summary: ${testsPassed}/${testsTotal} passed.`); | ||
|
|
||
| if (testsPassed === testsTotal) { | ||
| // Output special string for script to catch | ||
| console.log("ALL_TESTS_PASSED_SUCCESSFULLY"); | ||
| } | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.