Fixing notice in google speed test results for inline forms

SOLVE
Akatziri
Member

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!

1 Accepted solution

Accepted Solutions
tjoyce
Solution
Recognized Expert | Platinum Partner

@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>

View solution in original post

3 Replies 3
dennisedson
Community Manager

@tjoyce , any advice you can offer here?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
tjoyce
Solution
Recognized Expert | Platinum Partner

@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>

View solution in original post

Akatziri
Member

Thanks!

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

 

0 Upvotes