you can exclude any inline JS by adding a (unique) keyword from it to AO’s comma-separated JS optimization exclusion list @geoogz, have a look at the AO FAQ for more info on how to exclude.
hope this helps,
frank
Thread Starter
George
(@geoogz)
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>
Like this one sir frank. It is possible to exclude it in aggregating js. I want to stay the code at the top of the head, not in the generated autoptimize file.
I excluded it but nothing change ‘seal.js,gtag.js,google-analytics.js’
-
This reply was modified 5 years, 6 months ago by George.
try adding your GA tracking ID (or gtag
), that should work 🙂
Thread Starter
George
(@geoogz)
Thank you so much (Y)
How about javascript like this one sir
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var animate = document.getElementsByClassName("animate"),
len = animate !== null ? animate.length : 0,
i = 0;
for (i; i < len; i++) {
animate[i].className += " active";
}
});
</script>
-
This reply was modified 5 years, 6 months ago by George.
for that I would try with animate[i].className
🙂
Thread Starter
George
(@geoogz)
Thanks a lot, sir!
I’m not familiar in javascript because it’s easy to use the jquery. But with your solution I think I need to target always the “function script”, is that right sir?
Thanks a lot, sir!
Please do call me Frank 🙂
I’m not familiar in javascript because it’s easy to use the jquery. But with your solution I think I need to target always the “function script”, is that right
to exclude inline JS from being aggregated you mean? sometimes the function name can indeed be used, unless if it’s not unique enough.
Thread Starter
George
(@geoogz)
Please do call me Frank 🙂
okay Frank 😀
Thank you again.
Mark as fixed