Hubspot Tracking Script Async & Defer

Dec 07, 2023
 — by 
Kris Kratz

A major drawback to the Hubspot Tracking script is that it slows down the initial webpage load time by a second or more.

This collects all of the information for the plugin after it loads.

I found a version of this on, but it wasn’t working for my version of Hubspot, so I fixed it.

// Hubspot Forms Defer Script ** FIXED **
// Source:
// Original
// Source:
// Replaced script with the one provided by Hubspot from the form's "share" button.
function hubspot_header() {