Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Rami Yushuvaev

    (@ramiy)

    If you have a GitHub repo, I can send a PR to solve the issue.

    If not, just add a defer attribute to all the scripts in this file:

    https://plugins.trac.www.ads-software.com/browser/leadin/trunk/src/class-pagehooks.php

    Plugin Support mlamacchia

    (@mlamacchia)

    Hi Rami, thanks for your message.

    What script in particular are you referring to?

    We are aware that the speed rank is affected by our tracking code and our team is currently working on it. However, the tracking code is already loaded using defer (check line 82).

    • This reply was modified 4 years, 6 months ago by mlamacchia.
    Thread Starter Rami Yushuvaev

    (@ramiy)

    @mlamacchia

    GTMatrix refers to the script loaded in line 116.

    See here: https://imgur.com/a/9eCUuFN

    Thread Starter Rami Yushuvaev

    (@ramiy)

    If you can’t add defer attribute, at least load the script asynchronously using async attribute…

    Thread Starter Rami Yushuvaev

    (@ramiy)

    Another solution is to add WordPress Hook to to your code (everywhere you load scripts). This way developers can change the code – for example a Filter Hook that passes an array of script attributes.

    I mean, I can change the plugin code, but the next plugin update will override my changes. WP hooks solve this issue.

    Again, if you have a GitHub repo, I can send a PR to solve the issue.

    Plugin Support mlamacchia

    (@mlamacchia)

    Hi Rami,

    Unfortunately, our code isn’t on GitHub yet.

    There is an inline script right after that one that relies on it, so adding defer isn’t enough. But we can, however, add a handler and run it on load.

    Our team is working on it, it’ll be live in around a week.

    Thanks for your help!

    Hello @ramiy. We are now releasing a new version that prevent the forms loading for blocking the rendering.

    Thanks for your help!
    Alvaro.

    Thread Starter Rami Yushuvaev

    (@ramiy)

    @mlamacchia @alortega

    The new plugin version didn’t solved the issue.

    When I view source the page, this is the code I see (I’ve removed the actual params):

    
    <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
    <script>
    hbspt.forms.create({
    portalId: "XXX",
    formId: "XXX",
    sfdcCampaignId: "XXX"
    });
    </script>
    

    You need to add defer or async attribute to the external script //js.hsforms.net/forms/v2.js in order to avoid render blocking.

    Hello @ramiy. Thanks for your submission. If I’m not mistaken there should be a second appearance in the code of
    <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
    which do contain the defer attribute, isn’t it?

    Here are the lines where we add them

    https://plugins.trac.www.ads-software.com/browser/leadin/trunk/src/class-pagehooks.php#L135

    https://plugins.trac.www.ads-software.com/browser/leadin/trunk/js/src/gutenberg/FormBlock/FormBlockSave.js#L27

    This bit of code you shared is generated by a different part of the application. We have already discuss this with the relevant people and they informed they have this modification in the roadmap but at the moment we do not have an estimation of when this will be released.

    Kind regards,
    Alvaro.

    • This reply was modified 4 years, 4 months ago by alortega.
    • This reply was modified 4 years, 4 months ago by alortega.
    • This reply was modified 4 years, 4 months ago by alortega.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Defer parsing of JavaScript’ is closed to new replies.