— which now fails with * "hbspt is not defined" because embed/v2.js initialises asynchronously. * * HubSpot's own Leadin plugin uses the hsFormsOnReady callback queue. * This shim creates a lightweight hbspt proxy that captures any * premature .forms.create() or .cta.load() calls and replays them * once the real library signals readiness via hsFormsOnReady. * * @see Leadin/public/utils/class-shortcoderenderutils.php */ (function(){ if (window.hbspt) return; // real lib already loaded var formsQ = []; var shim = { forms: { create: function(opts) { formsQ.push(opts); } } }; window.hbspt = shim; window.hsFormsOnReady = window.hsFormsOnReady || []; window.hsFormsOnReady.push(function(){ if (window.hbspt === shim) return; // real lib never loaded; bail for (var i = 0; i < formsQ.length; i++) { hbspt.forms.create(formsQ[i]); // real hbspt at this point } }); })();