Fixing notice in google speed test results for inline forms

Hi,

We are using a WP install with inline Hubspot forms embed like so

<!--[if lte IE 8]>
<script charset=“utf-8” type=“text/javascript” src=“//js.hsforms.net/forms/v2-legacy.js”></script>
<![endif]-->
<script charset=“utf-8” type=“text/javascript” src=“//js.hsforms.net/forms/v2.js defer async”></script>
<script>
hbspt.forms.create({
portalId: “#######”,
formId: “###################”
});
</script>

We are trying to defer or stop the inline script from initel loading for some time or only after page load to imporve the site speed load and the google speed test results but with no luch, when we put the forms in an onload event they will not show,

Is there a workaround to delay the load of inline Hubspot?

Thanks!

@tjoyce , any advice you can offer here?

@Akatziri - Can you please provide the code you are using to render the form on page load?

This is certainly possible by adding a target to your form initialization.

<div id="myForm"></div>
<script>
setTimeout(function(){
 hbspt.forms.create({
 portalId: "#######",
 formId: "###################",
 target: "#myForm"
 });
}, 3000)
</script>

Thanks!

I solved the issue and made the notice go away, thanks for the help