[Resolved] Advice for third-party code lazy loading?

Home Forums Support [Resolved] Advice for third-party code lazy loading?

Home Forums Support Advice for third-party code lazy loading?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1544796
    Andy

    Hi there,

    After installing some third-party Ad code (javascript), I noticed my site takes a huge hit on speed tests. Google recommends: “Third-party code blocked the main thread. Third-party code can significantly impact load performance. Limit the number of redundant third-party providers and try to load third-party code after your page has primarily finished loading.”

    Do you guys have any advice on how to load javascript Ad code after my page finishes loading? I’m sure I can find something online. But, I’m wondering if there are any methods/plugins that work well with GenereatePress?

    Thank you

    #1544916
    Leo
    Staff
    Customer Support

    Hi there,

    Where are you adding the code currently?

    #1544939
    Andy

    Hi Leo,

    1 – sidebar

    1 – body of a single post

    1 – maybe in a floating banner at the bottom of the screen

    Thank you

    #1544944
    Leo
    Staff
    Customer Support

    Like you added Javascript directly into those places?

    If so there is no way around it unfortunately.

    Usually Javascript goes into wp_footer with a hook element:
    https://docs.generatepress.com/article/hooks-element-overview/

    And it would be the last thing to load.

    #1544948
    Andy

    Ok brilliant! I’ll try that! Thank you Leo

    #1544950
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.