perf(handler): consolidate per-component template scripts into single script tag#209
Merged
mohamedmansour merged 1 commit intomainfrom Apr 9, 2026
Merged
Conversation
99f85cf to
5966851
Compare
Strip the <script>...</script> wrapper from compiled template output in webui-parser. Templates are now stored as raw JS IIFE strings in the protocol. - Parser: generates raw JS IIFE body, no <script> wrapper - SSR (webui.rs plugin): wraps all templates in a single <script> tag - Partials: sends raw JS strings directly in the templates array - Router: evaluates raw JS via script element, no parsing needed - FAST plugin: unchanged (uses <f-template> DOM elements) This reduces SSR HTML size (1 script tag instead of N), eliminates client-side <script> tag parsing for partial navigation, and cleanly separates the transport format from the template content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5966851 to
df5d9c9
Compare
akroshg
approved these changes
Apr 9, 2026
janechu
reviewed
Apr 9, 2026
| if (this.nonce) script.nonce = this.nonce; | ||
| script.textContent = tmpl; | ||
| document.head.appendChild(script); | ||
| document.head.removeChild(script); |
Contributor
There was a problem hiding this comment.
Append then remove? I think a comment here would be good, I assume the IIFE inside the script executes, then is no longer needed so removed so as to keep the document as small as possible when switching routes, each of which may add and remove an IIFE. Is that correct?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge N individual <script> IIFE blocks into one consolidated <script> tag during SSR template emission. Templates using the standard IIFE pattern (w['tag']={...}) are extracted and combined into a single IIFE, reducing HTML parse overhead and eliminating N-1 script element evaluations.
Non-standard templates fall back to individual <script> tags for backward compatibility.