Joomla! extension to conditionally load Optimizely snippet
I've created a Joomla! extension to conditionally load the Optimizely plugin directly after <head> tag.
Recently we've started using Optimizely on https://www.byte.nl
We've noticed a 1.5sec delay in loading time of our website due to Optimizely.
Since we don't need Optimizely on every page of our Joomla! website I've created a plugin so every marketeer can activate / deactivate the Optimizely snippet.
Feel free to use the plugin yourself. Just download, install, configure the plugin with your Project ID and activate the menu items where you want to load the Optimizely code.
Thanks for sharing your plugin with the Optimizely community. It is sounds like a very useful extension.
I am surprised to hear about your loading time, this is really unusual. Optimizely uses two content delivery networks to provide you with the best possible performance and the snippet generally loads within less than 100ms, assuming a file size of 35kb.
More information about the CDN balancer can be found here
There might be a chance that you were facing a problem with your internet connection or your internet service provider. If you continue to see problems I recommend checking with your ISP because we have seen these kinds of problems in the past.
Here are some general tips how to slim down the snippet size and speed up the loading time:
- Archive all non-essential experiments and/or turn on the Project Settings option to exclude paused and draft experiments from the snippet
- If you are already loading a copy of jQuery on your page, consider excluding jQuery entirely from the snippet
- Archive and/or delete old audiences, goals and dimension
- Move the Optimizely script as high up the page as possible
- That way it has the greatest possible chance of loading before any elements are parsed and is not blocked by other scripts
- Check the network tab to see if any scripts in particular are blocking Optimizely - can Optimizely be loaded prior to these?
- Switch the snippet to async loading (recommended as a last resort)
- This should be fine if the changes you are making are below the fold
- Self-host the snippet (recommended as a last resort)
- Some customers (i.e. those in areas where our CDNs don’t have great coverage) have had great success self-hosting the snippet and writing a program which requests the new version from our servers every couple of minutes. However, this isn’t really something that should be done lightly.
I hope that is helpful!
EMEA | Amsterdam
Thank you for your reply.
"There might be a chance that you were facing a problem with your internet connection or your internet service provider." I've tested the loading speed of the website using https://tools.pingdom.com from a server in Amsterdam, The Netherlands. I've chosen this server since our website https://www.byte.nl is in The Netherlands too. It seems that the results vary a lot. From acceptable fast to too slow.
Thank you for the general tips how to slim down the snippet size and speed up loading time.
"1. Archive all non-essential experiments and/or turn on the Project Settings option to exclude paused and draft experiments from the snippet"
We had some "paused" projects. I've archived them.
"2. If you are already loading a copy of jQuery on your page, consider excluding jQuery entirely from the snippet"
We are loading jQuery. But the Optimizely code is loaded before jQuery is loaded. Can I safely exclude jQuery entirely from the snippet?
"3. Archive and/or delete old audiences, goals and dimension"
We had some unused Goals. I've archived them
With the plugin I created Optimizely code is loaded directly after <head> using a string replace <head> with <head><script....
thanks again for your reply. I've implemented your general tips hoping the loading time of optimizely script will be faster.
Then again.. using my Joomla! plugin will you allow to load Optimizely script only on the pages needed.
I would suggest to have a closer look at your loading time issue seperately. Lets switch to email communication for a better troubleshooting. I will send you an email shortly.
Regarding your question about jQuery, yes you can safely exclude jQuery from the project code as long as you are using the right version and jQuery is loaded before the Optimizely snippet.
As you mentioned before, jQuery is loading on your website after the snippet. If you move the jQuery script above the Optimizely snippet it would work, otherwise not. Detailed information can be found here.
All the best,
EMEA | Amsterdam