Fix the GoHighLevel form sometimes not appearing on /contact/

form_embed.js hides each embed off-screen until the iframe reports ready.
With loading="lazy" the hidden iframe often never loaded, so it never
reported ready and the form stayed invisible. Load the form eagerly, reserve
its height, and reveal any embed still hidden after a few seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alejandro Veras
2026-10-15 12:12:57 -04:00
parent 75d8cbc7f7
commit 4ba5f05f75
3 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -263,6 +263,6 @@ ${scripts}
// GoHighLevel embeds. form_embed.js resizes the iframes to their content.
export const GHL_SCRIPT = '<script src="https://link.msgsndr.com/js/form_embed.js" defer></script>';
export const ghlForm = (id, name) =>
`<iframe class="ghl-frame" src="https://api.leadconnectorhq.com/widget/form/${id}" id="inline-${id}" title="${name}" data-layout="{'id':'INLINE'}" data-trigger-type="alwaysShow" data-trigger-value="" data-activation-type="alwaysActivated" data-activation-value="" data-deactivation-type="neverDeactivate" data-deactivation-value="" data-form-name="${name}" data-layout-iframe-id="inline-${id}" data-form-id="${id}" loading="lazy"></iframe>`;
`<iframe class="ghl-frame" src="https://api.leadconnectorhq.com/widget/form/${id}" id="inline-${id}" title="${name}" data-layout="{'id':'INLINE'}" data-trigger-type="alwaysShow" data-trigger-value="" data-activation-type="alwaysActivated" data-activation-value="" data-deactivation-type="neverDeactivate" data-deactivation-value="" data-form-name="${name}" data-layout-iframe-id="inline-${id}" data-form-id="${id}"></iframe>`;
export const ghlCalendar = (id, title) =>
`<iframe class="ghl-frame ghl-cal" src="https://api.leadconnectorhq.com/widget/booking/${id}" id="${id}_cal" title="${title}" scrolling="no"></iframe>`;
+22
View File
@@ -143,5 +143,27 @@
});
}
// GoHighLevel's form_embed.js hides each embed until the iframe reports it is
// ready. If that message never arrives, show the embed anyway so the form is
// never left invisible.
var reveal = function (f) {
f.style.opacity = '1';
f.style.visibility = 'visible';
f.style.pointerEvents = 'auto';
f.style.position = 'relative';
if (f.style.left === '-9999px') f.style.left = '';
};
var ghl = document.querySelectorAll('.ghl-frame');
if (ghl.length) {
[2500, 6000].forEach(function (ms) {
setTimeout(function () {
ghl.forEach(function (f) {
if (f.closest('[data-off]')) return;
if (getComputedStyle(f).visibility === 'hidden') reveal(f);
});
}, ms);
});
}
root.classList.add('ready');
})();
+2
View File
@@ -1046,3 +1046,5 @@ h1, h2, h3, h4 { font-weight: 600; }
@media (max-width: 760px) { .calls { grid-template-columns: 1fr; } .call { padding: 24px; } }
#schedule .wrap { position: relative; }
.cal-panel[data-off] { position: absolute; left: -10000px; top: 0; width: min(980px, 100%); visibility: hidden; pointer-events: none; }
.ghl-wrap-form { min-height: 460px; }
.ghl-wrap-cal { min-height: 720px; }