You should change your php code to the following:
function add_async_to_forms_script( $tag, $handle ) {
if ( 'leadin-forms-v2' === $handle ) {
$tag = str_replace( 'src', 'async src', $tag );
}
return $tag;
}
add_filter('script_loader_tag','add_async_to_forms_script'
)
You can simplify you page code to the following:
<script>
window.hsFormsOnReady = window.hsFormsOnReady || [];
window.hsFormsOnReady.push(()=>{
hbspt.forms.create({
region: "na1",
portalId: "8419634",
formId: "d0de9b78-f8c6-4b96-b2fd-c2e78e483a5f",
target: "#your-div-id",
})
});
</script>
-
This reply was modified 1 year, 7 months ago by harthur90.
-
This reply was modified 1 year, 7 months ago by harthur90. Reason: editor
-
This reply was modified 1 year, 7 months ago by harthur90. Reason: wp editor
-
This reply was modified 1 year, 7 months ago by harthur90. Reason: add region