Fix: iframe mount delay of embedded chatbot (#17167)

This commit is contained in:
KVOJJJin
2025-03-31 14:25:39 +08:00
committed by GitHub
parent 44f911a0a8
commit cf05e9cf78
2 changed files with 25 additions and 18 deletions

View File

@@ -57,6 +57,13 @@
// pre-check the length of the URL
const iframeUrl = `${baseUrl}/chatbot/${config.token}?${params}`;
// 1) CREATE the iframe immediately, so it can load in the background:
const preloadedIframe = createIframe();
// 2) HIDE it by default:
preloadedIframe.style.display = "none";
// 3) APPEND it to the document body right away:
document.body.appendChild(preloadedIframe);
// ─── End Fix Snippet
if(iframeUrl.length > 2048) {
console.error("The URL is too long, please reduce the number of inputs to prevent the bot from failing to load");
}