How to minify "Google Optimize" javascript file

Viewed 366

I have look everywhere for an answer for this and cannot find an answer. Just to be clear, i am not asking how to minify js but specifically the Google Optimise js files which are 3rd party.

We use "Google Optimize" for a/b testing etc which we load in through Google Tag Manager.

Does anyone know how to minify the "Google Optimize" javascript as we always get marked down on PageInsights for it?

1 Answers

The only way I can think of that lets you minify it without adding overhead to each request is to cache and minify locally and serve it from your own server.

So write a back-end script that downloads the script every hour or so, minifies it and then caches that version at some URL.

Then instead of loading the script from Google CDN you serve it from your own CDN / server.

Related