No debounce on the live markdown preview — full parser re-runs on every keystroke #108

Open
opened 2026-09-01 00:21:14 -04:00 by jared · 0 comments
Owner

Severity: Low

assets/js/ticket.js (updatePreview, wired via textarea.addEventListener('input', updatePreview), ~lines 340,346-361) calls parseMarkdown() synchronously on every keystroke with no debounce/throttle. parseMarkdown() is a chain of ~15+ sequential regex .replace() passes over the full text, so on a long comment this re-runs the entire regex chain on every character typed.

Likely fine for typical comment lengths, but there's no debounce present at all, unlike the shared lt.typeahead/lt.combobox modules elsewhere in the same codebase, which do debounce (150ms). Not confirmed as user-visible lag today, just an inconsistency worth flagging since a slow client + a long comment could make typing feel laggy.

Fix: Add a small debounce (e.g. 100-150ms) to updatePreview's input handler, matching the pattern already used by the typeahead modules.

**Severity:** Low `assets/js/ticket.js` (`updatePreview`, wired via `textarea.addEventListener('input', updatePreview)`, ~lines 340,346-361) calls `parseMarkdown()` synchronously on every keystroke with no debounce/throttle. `parseMarkdown()` is a chain of ~15+ sequential regex `.replace()` passes over the full text, so on a long comment this re-runs the entire regex chain on every character typed. Likely fine for typical comment lengths, but there's no debounce present at all, unlike the shared `lt.typeahead`/`lt.combobox` modules elsewhere in the same codebase, which do debounce (150ms). Not confirmed as user-visible lag today, just an inconsistency worth flagging since a slow client + a long comment could make typing feel laggy. **Fix:** Add a small debounce (e.g. 100-150ms) to `updatePreview`'s input handler, matching the pattern already used by the typeahead modules.
jared added the performancepriority/low labels 2026-09-08 10:15:51 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/tinker_tickets#108