Leverage browser caching - HS Scripts

New Contributor

Hello Folks


We are using HS tracking & Form Embed scripts on our website. While running speedtest on multiple tools, we found HS scripts majorly impact the website performance. We have tested it without HS scripts  and results are quite interesting like atleast 7-10% increased once after removing HS scripts.


Can anyone suggest what we can do or how can we optimize them.

1 Reply 1
HubSpot Moderator

Hi @ashishkumar,


Regarding the tracking code, this is loaded asycnhronously and deferred, along with any other scripts loaded through the tracking code. So those scripts should be optimized for page load speed already. The embedded forms are just loaded through the embed code, but you could potentially play around with using your own forms and submitting to our Forms API. The form submission endpoint documented here: https://developers.hubspot.com/docs/methods/forms/submit_form_v3 does have AJAX support, so you could submit right from your page.


The only other thing I'd add is that we've had people in the past ask about page optimization tools. So if you do some searching around this Community, you might find some similar threads related to those kinds of questions. You might find some helpful info in these for example: https://community.hubspot.com/t5/CMS-Development/PageSpeed-Insights/m-p/27784, https://community.hubspot.com/t5/CMS-Development/How-do-I-disable-JavaScript-and-CSS-render-blocking....


Let me know if you have any other questions about it.


Leland Scanlan

HubSpot Developer Support