CMS Development

Akatziri
メンバー

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!

1件の承認済みベストアンサー
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Fixing notice in google speed test results for inline forms

解決

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

元の投稿で解決策を見る

3件の返信
Akatziri
メンバー

Fixing notice in google speed test results for inline forms

解決

Thanks!

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

 

0 いいね!
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Fixing notice in google speed test results for inline forms

解決

@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製品開発チーム
HubSpot製品開発チーム

Fixing notice in google speed test results for inline forms

解決

@tjoyce , any advice you can offer here?