Script in head loading very late

Dear support,
Ive added a script from visualwebsiteoptimizer (VWO) to my wp_head from my functions.php
Now according to my page source, this script is showing at the end of my <head tag right before the </head tag.
Thats great.
But when i go to webpagetest or any testing tool, im seeing that my VWO code is being loaded very late, even after the scripts that are found in my <body

Example: https://www.webpagetest.org/result/170706_7G_1GC4/1/details/
(Loaded at Number 56)

Can you please let me know why is this happening and how to fix it ?
I need the vwo code to load very early on, right after the jquery loads.
Thanks

This is an automated message to notify you that your thread was posted in the wrong forum, and it has been moved to the correct place. A member of our team will be happy to reply just as soon as your thread is up.

For support, all questions are to be posted in the Themeco category or by clicking + Support. The other categories are for discussion with fellow Apex members. Please keep this in mind in the future. Thank-you!

How support works.

1 Like

Hi there,

The wp_head action is one of the default Wordpress features and not related to our theme specifically actually. Wordpress gives an option to set the priority of the script loading. To make use of that please follow up this article:

http://hookr.io/actions/wp_head/

On the example you will see this:

add_action( ‘wp_head’, ‘action_wp_head’, 10, 2 );

The 10 and 2 numbers are the priority numbers which you can play with to achieve the proper result.

As this is a default feature of the Wordpress you will need to follow up the case with Wordpress support:

https://wordpress.org/support/

Thank you for your understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.