From 5bec91ab173a790ea676544eb756baa071000d76 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 16 May 2026 22:25:44 +0200 Subject: [PATCH] perf(overlay): only ship editor assets to pages that mount an editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses Important #2 from the final code review. The asset partial was previously included unconditionally for any overlay detail page. Workshop overlays and read-only files-type overlays (when the viewer isn't the owner or admin) have no data-editor-language textarea, so the ~30 KB of Prism + CodeJar + JS + CSS shipped pointlessly. Gate the include on the two cases that actually mount an editor: script-type overlays (bash editor) and files-type overlays where the current user has edit rights (the files-editor modal). I-1 from the review (race window during "Loading…") was confirmed moot — editorDialog.showModal() only fires after the fetch resolves (files-overlay.js:409), so the dialog is invisible during the fetch-and-placeholder window and the user can't type into it. I-3 (Playwright coverage of the language dropdown override) is real follow-up work that needs a new files-type overlay seed in the live_server fixture. Deferred as a v2 ticket. Co-Authored-By: Claude Opus 4.7 (1M context) --- l4d2web/l4d2web/templates/overlay_detail.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/l4d2web/l4d2web/templates/overlay_detail.html b/l4d2web/l4d2web/templates/overlay_detail.html index c570bbe..19962f1 100644 --- a/l4d2web/l4d2web/templates/overlay_detail.html +++ b/l4d2web/l4d2web/templates/overlay_detail.html @@ -282,5 +282,11 @@ {% endif %} -{% include '_editor_assets.html' %} +{# Only include the ~30 KB of editor assets on pages that actually mount + an editor: script-type overlays (bash editor) and files-type overlays + that the current user can edit (the files-editor modal). Workshop + overlays and read-only pages skip the include entirely. #} +{% if overlay.type == 'script' or files_can_edit %} + {% include '_editor_assets.html' %} +{% endif %} {% endblock %}