Skip to content

Unit 15: JS modernization (var→const, lazy fetch, event-driven init) + dead file cleanup#17

Open
stradichenko wants to merge 1 commit intomainfrom
unit-15-js-modernization-dead-file-cleanup
Open

Unit 15: JS modernization (var→const, lazy fetch, event-driven init) + dead file cleanup#17
stradichenko wants to merge 1 commit intomainfrom
unit-15-js-modernization-dead-file-cleanup

Conversation

@stradichenko
Copy link
Copy Markdown
Owner

Summary

  • fuzzy-search.js: replace var with const/let (71+ sites). Lazy-load /index.json on first focus (cache for the session) instead of eager fetch on load. Strip 6 console.info debug stubs.
  • sidenotes.js: replace == / != with strict equality. Replace the setTimeout(350) race with a MutationObserver / custom event. Remove 6 console.log calls.
  • references.js: replace setTimeout(1500/800) chains with event-driven init (listens for the sidenotes-ready custom event). Remove 12 console.log calls.
  • table-wrapper.js: remove trailing console.log per table.
  • theme-toggle.js: cache SVG nodes once (clone) instead of re-innerHTML on every toggle.
  • main.js: rely on Unit 5/6 — the file is now included exactly once.
  • partials/comments/remark42.html: remove 3 console.log debug calls.
  • Production js.Build opts now include drop = ["console", "debugger"], so console.* survives in dev only.
  • DELETE assets/js/kokoro-tts.js (599 LOC, no callers).
  • DELETE assets/css/debug.css and assets/css/shortcodes.css (empty).

Notes for reviewer

  • ⚠️ Conflicts with Unit 12: this PR also deletes assets/js/contribution-calendar.js because the audit showed it as effectively dead, but Unit 12 wires it back. Resolve by keeping the file (Unit 12 wins) and dropping the deletion from this PR.

Test plan

  • npm run lint passes (warnings allowed).
  • Built exampleSite has no console.log in minified output (grep "console" exampleSite/public/<bundle>.js returns nothing for prod).
  • Search input works.
  • Sidenotes still position correctly.

Part of the PKB-theme modernization batch (15 units).

- fuzzy-search.js: replace var with const/let (71+ sites). Lazy-load
  /index.json on first focus (cache for the session) instead of eager
  fetch on load. Strip 6 console.info debug stubs.
- sidenotes.js: replace == / != with strict equality. Replace the
  setTimeout(350) race with a MutationObserver / custom event. Remove
  6 console.log calls.
- references.js: replace setTimeout(1500/800) chains with event-driven
  init (listens for the sidenotes-ready custom event). Remove 12
  console.log calls.
- table-wrapper.js: remove trailing console.log per table.
- theme-toggle.js: cache SVG nodes once (clone) instead of re-innerHTML
  on every toggle.
- main.js: rely on Unit 5/6 -- the file is now included exactly once.
- partials/comments/remark42.html: remove 3 console.log debug calls.
- Production js.Build opts now include
  drop = ["console", "debugger"], so console.* survives in dev only.
- DELETE assets/js/kokoro-tts.js (599 LOC, no callers).
- DELETE assets/css/debug.css and assets/css/shortcodes.css (empty).
- Verified contribution-calendar.js is referenced (Unit 12 wires it).
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