While working on a Vue page, I encountered an issue with loading multiple Hubspot forms simultaneously. Only one form would load at a time.
Here is the code snippet I used to append a single Hubspot form:
mounted() {
const script = document.createElement("script");
script.src = "https://js.hsforms.net/forms/v2.js";
document.body.appendChild(script);
script.addEventListener("load", () => {
if (window.hbspt) {
window.hbspt.forms.create({
portalId: "1791848",
formId: "ffad341d-b632-4280-a0c7-7141007bac69",
target: "#hubspotForm",
});
}
});
},