Google PageSpeed score is being negatively affected by HubSpot network requests

SOLVE
Highlighted
Occasional Contributor

Our Google PageSpeed score is being negatively affected by hubspot network requests.

Though these scripts are being loaded defered and async, they still are calculated into the overall page load times for Google's metric. 

1.) Can anything be done to lighten these, or at least follow the guidelines Google is asking for for a better user experience?

 

hs-scripts.JPG

2.) Can you put a cache policy onto the below static assets? Google suggests "Cache-Control: max-age=31536000".  If you need to update these resources, why not use a url revision query?

serve-static-assets-with-cache-policy.JPG

3.) If your chatbot needs to download 6 fonts, at least use the font-display css value of "swap" so that it can use a system font until the fonts are fully loaded.

text-remains-visible-during-load.JPG

4.) It's time to get jQuery removed as a dependency. It's used for the chatbot, and the forms embed script callbacks as it relates to our site. It's added weight we don't need - modern websites and apps are not using it anymore in favor of what javascript can do natively now.  

5.) Can you remove the default styling in the forms embed that is injected into the head of the document?  If I am selecting "Unstyled Form", that's what I should actually get so I can style the forms in my own stylesheet.  This small change would allow me not to have to go to the troulble of rebuilding all my forms using the Forms API.

6.) Because of the chatbot specifically, our site's Mobile pagespeed score is "Slow".  There isn't a way to disable it for mobile, only a hack of using css to hide it which doesn't solve anything - still requests all the above offending resources.

Making these changes or suggesting solutions that work would be a step to helping out those of us concerned with site optimization as it pertains to SEO and overall performance for our users/customers.

Supporting backward compatibility for old browsers and/or hubspot users' legacy code is understandable but those of us utilizing current web standards shouldn't have to suffer. HubSpot is an expensive product to not be at the top of it's game when it comes to these concerns.


Thank you

1 Accepted solution

Accepted Solutions
Highlighted
Solution
New Contributor

You can put it anywhere. I would recommend putting HS lib scripts in the header.

 

Put it in the header-->

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js" async></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js" async></script>

 

Then you need to make sure the scroll function should always come after jQuery lib anywhere in your document.

 

jQuery(window).scroll(function() {
    if (!jQuery('.hbspt-form').length) {
        hbspt.forms.create({
            portalId: "PORT_ID",
            formId: "YOUR_FORM_ID"
        });
    }
});

 And you can easily make dynamic PORT_ID and FORM_ID. Shown below using PHP.

 

<script>
jQuery(window).scroll(function() {
    if (!jQuery('.hbspt-form').length) {
        hbspt.forms.create({
            portalId: "<?php echo $port_id; ?>",
            formId: "<?php echo $form_id; ?>"
        });
    }
});
</script>

 

View solution in original post

9 Replies 9
Highlighted
Community Manager

Hi @nstoffel,


I wanted to direct you to this thread where I recently shared information and resources around page speed and HubSpot.

 

I especially want to highlight this resource which discusses HubSpot and site speed in great detail. 

 

Thank you,
Jenny


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
0 Upvotes
Highlighted
Occasional Contributor

Thanks but i've already used those methods to optimize my site.

 

I guess I will have to reach out to support directly to try and get any answers.

0 Upvotes
Highlighted
Regular Contributor

you have to optimize your website errors and issue which are highlighted by google page speed score, after that periodically check the speed of your site and make a monthly report.

Highlighted
New Member

We're experiencing this too. It's an issue.

 

Neither of the answers supplied correctly understand the issue the orignal poster is having.

The issue is with the code which Hubspot injects into our websites via its plugins - so it is completely outside of the control of the webmaster to make changes to this.


Would be good to see improvements here - we are seeing dramatic performance decline on some of our sites after installing the chatbot and forms.

Highlighted
New Contributor
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js" async></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js" async></script>
<script>
jQuery(window).scroll(function() {
    if (!jQuery('.hbspt-form').length) {
        hbspt.forms.create({
            portalId: "PORT_ID",
            formId: "YOUR_FORM_ID"
        });
    }
});

</script>

Use this. Basically we are adding to both async attribute scripts above. And load form on the scroll when the user scroll. You may need to change some logic according to your need. Let me know if I can help you with something. 

Highlighted
New Contributor

hi @sandeep4467.

 

This type of script realy help to eliminate some problems, but not the most of them. The real problem isn't in what is been loaded on hubspot forms, but in whats is been loaded on hubspot chatbot.

0 Upvotes
Highlighted
Regular Contributor

Hi Sandeep, I am a little new to hubspot... where would we use this script? Would it be installed in the template or somewhere in the header of page? 


I was also wondering if : portalID and formID can be dynamic rather than having to manually update the form for each page?

0 Upvotes
Highlighted
Solution
New Contributor

You can put it anywhere. I would recommend putting HS lib scripts in the header.

 

Put it in the header-->

<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js" async></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js" async></script>

 

Then you need to make sure the scroll function should always come after jQuery lib anywhere in your document.

 

jQuery(window).scroll(function() {
    if (!jQuery('.hbspt-form').length) {
        hbspt.forms.create({
            portalId: "PORT_ID",
            formId: "YOUR_FORM_ID"
        });
    }
});

 And you can easily make dynamic PORT_ID and FORM_ID. Shown below using PHP.

 

<script>
jQuery(window).scroll(function() {
    if (!jQuery('.hbspt-form').length) {
        hbspt.forms.create({
            portalId: "<?php echo $port_id; ?>",
            formId: "<?php echo $form_id; ?>"
        });
    }
});
</script>

 

View solution in original post

Highlighted
Regular Contributor

Thank you so much, that was super helpful!!

0 Upvotes