From eed3b43252548f7f5965f112775509b86b8933b5 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Sat, 10 Aug 2024 18:40:38 +0900 Subject: [PATCH 1/2] remove preconnects --- modules/ui_gradio_extensions.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ui_gradio_extensions.py b/modules/ui_gradio_extensions.py index ed57c1e98..b952762cc 100644 --- a/modules/ui_gradio_extensions.py +++ b/modules/ui_gradio_extensions.py @@ -1,4 +1,5 @@ import os +import re import gradio as gr from modules import localization, shared, scripts, util @@ -49,12 +50,19 @@ def css_html(): return head +re_preconnect = re.compile(rb']*)?/?>') + + def reload_javascript(): js = javascript_html() css = css_html() def template_response(*args, **kwargs): res = shared.GradioTemplateResponseOriginal(*args, **kwargs) + + # remove preconnects + res.body = re_preconnect.sub(b'', res.body) + res.body = res.body.replace(b'', f'{js}'.encode("utf8")) res.body = res.body.replace(b'', f'{css}'.encode("utf8")) res.init_headers() From 4861dccf7c2114e3782747e9f39c3c64e723e2f3 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Sat, 10 Aug 2024 19:34:01 +0900 Subject: [PATCH 2/2] local iframeResizer load iframeResizer from webui assets ASSETS_COMMIT_HASH needs to be updated accordingly after https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets/pull/2 is merged --- modules/ui_gradio_extensions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ui_gradio_extensions.py b/modules/ui_gradio_extensions.py index b952762cc..73ddef901 100644 --- a/modules/ui_gradio_extensions.py +++ b/modules/ui_gradio_extensions.py @@ -62,7 +62,9 @@ def reload_javascript(): # remove preconnects res.body = re_preconnect.sub(b'', res.body) - + # replace iframeResizer with local version + res.body = res.body.replace(b'src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.6/iframeResizer.contentWindow.min.js"', b'src="webui-assets/js/iframe-resizer/4.3.6/iframeResizer.contentWindow.min.js"') + res.body = res.body.replace(b'', f'{js}'.encode("utf8")) res.body = res.body.replace(b'', f'{css}'.encode("utf8")) res.init_headers()