-
Notifications
You must be signed in to change notification settings - Fork 1
Defer JavaScript and jQuery
If you care about page performance scoring you may be looking on how to defer the loading of Abrantes to improve your score. Please note that Abrantes is a very small JavaScript library and it does not impact your performance noticeably in normal circumstances. The score is a measurement and sometimes a higher score doesn't translate to a better user experience.
You can defer Abrantes JavaScript, but please note that's not recommended because:
- It will show a momentary flash when the page switches to the variant after loading. You can manage this to make it less perceptible or show a blank page momentarily. In both cases it's less efficient than the default setting. Please note that Google Optimize also has also this issue, and you can not avoid it with Optimize.
- You must ensure the correct script execution order by: 1) Running the gtag script in the footer also with a defer 2) Create your test in an external JavaScript file.
On the other hand, if you need to run jQuery (or other libraries) in your tests code, running in defer mode might be your only option.
Because with Abrantes you can add scripts to the original variant, in most situations it's better to manage the content switch flash rather than adding a blank screen like Google Optimize and other similar tools.
Please look at the defer example to see how it could work.