From d65efed032defa2f0759862540fccedd4325ee80 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Tue, 17 Dec 2024 12:31:26 -0500 Subject: [PATCH] render page-script elements at end of head content --- Oqtane.Client/UI/Head.razor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Oqtane.Client/UI/Head.razor b/Oqtane.Client/UI/Head.razor index 1b030789..0d72ce98 100644 --- a/Oqtane.Client/UI/Head.razor +++ b/Oqtane.Client/UI/Head.razor @@ -70,10 +70,13 @@ var pagescript = script.Replace("script", "page-script"); if (!pagescript.Contains("><")) { + // convert inline script body to content attribute var content = pagescript.Substring(pagescript.IndexOf(">") + 1, pagescript.LastIndexOf("<") - pagescript.IndexOf(">") - 1); pagescript = pagescript.Replace(">" + content, " content=\"" + content.Replace("\"","'") + "\">"); } - headcontent = headcontent.Replace(script, pagescript); + // move page-script to end of headcontent as Blazor will move anything after a page-script element to the top of the body + headcontent = headcontent.Replace(script, ""); + headcontent = headcontent + pagescript; } index = headcontent.IndexOf("