⚡ Bolt: Prevent redundant DOM updates on initial i18n load#7
Conversation
- Cache DOM queries so they only run once - Add early return if active language matches requested language - Only update textContent if it has actually changed
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
OpenCode Review Overview
|
There was a problem hiding this comment.
OpenCode Agent approved this PR.
The changes optimize i18n DOM updates by adding caching and equality checks. The implementation correctly handles all edge cases and maintains functionality while reducing unnecessary layout operations. No security or regression risks found.
- Result: APPROVE
- Reason: Performance improvements with proper safety checks
- Head SHA:
d6df237202682fe117cf20f9c461d6dc313e6585 - Workflow run: 27873923247
- Workflow attempt: 1
💡 What:
Optimized the
setLanguagefunction ini18n.jsto cache DOM node queries (querySelectorAll,querySelector) and verify if the requested language text actually differs before updating the DOM'stextContentor attributes.🎯 Why:
The initial
setLanguagecall redundantly selected every translatable node on the page and updated its text content to the default Korean language. However, the HTML markup is already localized in Korean. Thus, the script initiated expensive, unnecessary blocking main thread work, triggering layout and paint re-calculations for content that didn't change.📊 Impact:
🔬 Measurement:
Start the local server (
python3 -m http.server 4173). Visiting the index without parameters performs almost zero DOM updates compared to before. Clicking the EN and KO buttons still translates correctly, visually verified through Playwright traces and logs.PR created automatically by Jules for task 1024467495292710943 started by @seonghobae