Skip to content

⚡ Bolt: Prevent redundant DOM updates on initial i18n load#7

Merged
github-actions[bot] merged 1 commit into
mainfrom
bolt-optimize-i18n-dom-updates-1024467495292710943
Jun 20, 2026
Merged

⚡ Bolt: Prevent redundant DOM updates on initial i18n load#7
github-actions[bot] merged 1 commit into
mainfrom
bolt-optimize-i18n-dom-updates-1024467495292710943

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

💡 What:

Optimized the setLanguage function in i18n.js to cache DOM node queries (querySelectorAll, querySelector) and verify if the requested language text actually differs before updating the DOM's textContent or attributes.

🎯 Why:

The initial setLanguage call 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:

  • Reduces Main Thread Blocking: Completely eliminates initial DOM updates for the default language.
  • Minimizes Repaints: Changing language now scales effectively as only the modified nodes trigger a re-render.
  • Reduces DOM Queries: Caching elements prevents repetitive, expensive tree parsing on every button click.

🔬 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

- 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
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: d6df237202682fe117cf20f9c461d6dc313e6585
  • Workflow run: 27873923247
  • Workflow attempt: 1
  • Gate result: APPROVE (exit 0)

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions github-actions Bot merged commit c11e967 into main Jun 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant