• Resolved Ian Ray

    (@ianthekid)


    Is there a reason why this is loaded so high up in the code? I understand you want to idiot-proof it, but it goes against best practices and affects the page loading process.

    I can easily change the wp_enqueue_script() to be in the footer, but any plugin update will overwrite that.

    Should be loaded in with wp_footer() like most JS. Could you add a setting for this maybe?

    https://www.ads-software.com/plugins/optimizely/

Viewing 2 replies - 1 through 2 (of 2 total)
  • @ianthekid – I believe this is to avoid the (in)famous “flicker of content”. By loading it early (render blocking) they try to minimize/avoid that the user see the original version before it’s changed to a variation.

    So yes, there’s definitely a reason ??

    Plugin Author bradtaylorsf

    (@bradtaylorsf)

    Hello @ianthekid

    Thank you for the post. As @michaelkjeldsen mentioned there is a method to our madness ??

    You are correct that a best practice is to load JS at the bottom of the page. However the way that Optimziely works is to load in all of the information about what is going to change on the page. This way as the page loads when elements become available in the DOM we can change it immediately without the user seeing a flash of the original content. If we placed the snippet at the bottom of the page, the user would see the original content, our snippet would load with the information about what has changed, then we would make the change. It would not be a good experience for the user.

    For more info on proper snippet placement and why, you can visit our knowledge base article here: https://help.optimizely.com/hc/en-us/articles/200040095

    Feel free to respond with any other questions you might have!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Load in Footer’ is closed to new replies.