• Resolved cp1132

    (@cp1132)


    adding defer or async both makes the form not load at all

    This works
    
    <script charset="utf-8" type="text/javascript" src="https://js.hsforms.net/forms/embed/v2.js"></script>
    <script>
      hbspt.forms.create({
        region: "na1",
        portalId: "8419634",
        formId: "3d0d5fbc-9869-405c-8e49-2e623e9585c7"
      });
    </script>
    This doesn't work
    
    <script defer charset="utf-8" type="text/javascript" src="https://js.hsforms.net/forms/embed/v2.js"></script>
    <script>
      hbspt.forms.create({
        region: "na1",
        portalId: "8419634",
        formId: "3d0d5fbc-9869-405c-8e49-2e623e9585c7"
      });
    </script>
    This doesn't work
    
    <script async charset="utf-8" type="text/javascript" src="https://js.hsforms.net/forms/embed/v2.js"></script>
    <script>
      hbspt.forms.create({
        region: "na1",
        portalId: "8419634",
        formId: "3d0d5fbc-9869-405c-8e49-2e623e9585c7"
      });
    </script>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Yes that is expected. That is why we use this wrapper

    <script>					
    window.hsFormsOnReady = window.hsFormsOnReady || [];
    window.hsFormsOnReady.push(()=>{
    	hbspt.forms.create({
                    region: "na1",
    		portalId: "8419634",
                    formId: "3d0d5fbc-9869-405c-8e49-2e623e9585c7",
                    target: "#your-div-id",
    		})
    });
    </script>

    Please note we do not offer support for custom script when it comes to form embedding and our help is limited on this case. We highly recommend you to make use of our Gutenberg block or Elementor Widget

    Best regards

    Thread Starter cp1132

    (@cp1132)

    I did the following but pagespeed is still complaining about the hubspot /forms/v2.js

    https://pagespeed.web.dev/analysis/https-ubigro-com/ui720iprp9?form_factor=mobile

    As mentioned in your last thread we added the performance issue reported by you to our backlog but we do not have a workaround at this moment.


    Please also note you should be using /forms/embed/v2.js and not /forms/v2.js


    I’ll close this issue as its original problem with async and defer has been resolved.

    Best regards

    @cp1132 How you fixed all the performance related issues and raised performance score?.

    I am also trying to achieve the same goal. following above method to optimize hubspot form

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘defer and async’ is closed to new replies.