CMS Development

Akatziri
Mitglied

Fixing notice in google speed test results for inline forms

lösung

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 Akzeptierte Lösung
tjoyce
Lösung
Trendsetter/-in | Elite Partner
Trendsetter/-in | Elite Partner

Fixing notice in google speed test results for inline forms

lösung

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

Lösung in ursprünglichem Beitrag anzeigen

3 Antworten
Akatziri
Mitglied

Fixing notice in google speed test results for inline forms

lösung

Thanks!

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

 

0 Upvotes
tjoyce
Lösung
Trendsetter/-in | Elite Partner
Trendsetter/-in | Elite Partner

Fixing notice in google speed test results for inline forms

lösung

@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>
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

Fixing notice in google speed test results for inline forms

lösung

@tjoyce , any advice you can offer here?