someone-in-the-world Claude Sonnet 4.6 commited on
Commit
421faaf
·
1 Parent(s): 9e24aab

Cache DOM elements and add no-op guard in status poller

Browse files

Cache #swap-status textarea and .loader-text once before the interval
instead of re-querying the DOM on every 300ms tick. Track lastText to
skip the DOM write when the status text hasn't changed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. static/wire_outputs.js +9 -5
static/wire_outputs.js CHANGED
@@ -362,12 +362,16 @@ function init() {
362
 
363
  function startStatusPolling() {
364
  stopStatusPolling();
 
 
 
 
365
  _statusPoller = setInterval(() => {
366
- const el = document.querySelector('#swap-status textarea');
367
- if (!el) return;
368
- const text = el.value.trim();
369
- const loaderText = document.querySelector('.loader-text');
370
- if (loaderText && text) loaderText.textContent = text;
371
  }, 300);
372
  }
373
 
 
362
 
363
  function startStatusPolling() {
364
  stopStatusPolling();
365
+ const statusEl = document.querySelector('#swap-status textarea');
366
+ const loaderText = document.querySelector('.loader-text');
367
+ if (!statusEl || !loaderText) return;
368
+ let lastText = '';
369
  _statusPoller = setInterval(() => {
370
+ const text = statusEl.value.trim();
371
+ if (text && text !== lastText) {
372
+ lastText = text;
373
+ loaderText.textContent = text;
374
+ }
375
  }, 300);
376
  }
377