Optimize on page form library loading




I'm in the process of migration our website to using HubSpot forms. Our website dependencies are nicely built with webpack using all kinds of optimization tricks to get the fastest page loading. 


The problem with HubSpot forms is that they require render-blocking loading "//js.hsforms.net/forms/v2.js" and rendering the form by using <script> tags inside html. This makes page loading inefficient.


Do you have a node module that I can use so I can add the library loading to my build process? And also create the forms outside of html and inside JS files? 


Otherwise I'd have to create a custom form for every lead gen form and use the API to submit the data. Which would be really inconvenient for our marketing team (and our developers who need to constantly change typos, fields etc).

2 Replies 2
HubSpot Alumni

Hi @markomessente,


I've moved your post over to our CMS development forum. I figured maybe someone here might have some ideas on how to reduce page load time.


To answer your question, there's no node module for HubSpot forms that I'm aware of. It sounds like you're aware of it already, but I think your best bet may be to use our form submission API for this. You'd basically use your own custom forms on your pages, but then submit to HubSpot forms using our API, documented here: https://developers.hubspot.com/docs/methods/forms/submit_form_v3. This would enable you to avoid the JS loading in from our embed code.


But I'd suggest submitting an idea for this: https://community.hubspot.com/t5/custom/page/page-id/ideaslandingpage. It seems like you have a pretty good idea of what you'd want the package to look like. I'm not sure if it's something we'd build out. But at the very least our CMS developers actively look for feedback.


Let me know if you have any questions here.


 - Leland

Leland Scanlan

HubSpot Developer Support

Thanks @lscanlan 


I figured there wasn't an easy solution to this. I'm using the submission API on some very custom forms already, but for simple forms (like case study downloads, newsletters etc) it would be useful if our marketing team could change the fields themselves (in HubSpot). With custom forms using API a developer would be needed to make any change in the form.


We have a separate CMS for our landing pages (but use HubSpot forms on it) and are currently not using HubSpot landing pages (we'll look into using it at some point).