Much better. Now we have left the options object being passed as h, i only being used as variable declaration, and d and e are unused other than making the original parameter list async hide.
document.documentElement represents the <html> element
.className += ' ' normalizes our variable to a String and is setting the class attribute on `
+ 'async-hide'; sets the class to async-hide which will be used later.
h.start = 1 * new Date(); sets on our options Object a time 1 second from now
h.end = i = function () sets the end property and assigns our i parameter a value
document.documentElement.className = document.documentElement.className.replace(RegExp(' ?' + 'async-hide'), '') really convoluted way to remove only the async-hide class from <html>
(window['dataLayer'] = window['dataLayer'] || []) grabs the dataLayer list from Google Tag Manager or returns an empty Array
.hide = h; sets the hide property to out options object
i(); calls our function to remove the class
h.end = null removes the reference to our function from the options object
h.timeout = 4000; the snippet waits 4 seconds before doing anything
So.
What this snippet does is assign a class, namely 'async-hide' to the <html> element of our document, waits 4 seconds, and then removes it.
Addendum, and I almost forgot! The CSS makes the entire document invisible. Presumably to wait for the page to load and hoping everything is done by then so as to not get a FOUC or similar.
TLDR: What this snippet does is assign a class, namely
'async-hide'to the<html>element of our document, waits 4 seconds, and then removes it.We have a self running function with a bunch of parameters but let's "prettify" it first.
Hmmm. That didn't help much. Okay. Let's replace all the parameters with their actual variables.
Much better. Now we have left the options object being passed as
h,ionly being used as variable declaration, anddandeare unused other than making the original parameter listasync hide.document.documentElementrepresents the<html>element.className += ' 'normalizes our variable to aStringand is setting theclassattribute on `+ 'async-hide';sets the class toasync-hidewhich will be used later.h.start = 1 * new Date();sets on our options Object a time 1 second from nowh.end = i = function ()sets theendproperty and assigns ouriparameter a valuedocument.documentElement.className = document.documentElement.className.replace(RegExp(' ?' + 'async-hide'), '')really convoluted way to remove only theasync-hideclass from<html>(window['dataLayer'] = window['dataLayer'] || [])grabs thedataLayerlist from Google Tag Manager or returns an empty Array.hide = h;sets thehideproperty to out options objecti();calls our function to remove the classh.end = nullremoves the reference to our function from the options objecth.timeout = 4000;the snippet waits 4 seconds before doing anythingSo.
What this snippet does is assign a class, namely
'async-hide'to the<html>element of our document, waits 4 seconds, and then removes it.Addendum, and I almost forgot! The CSS makes the entire document invisible. Presumably to wait for the page to load and hoping everything is done by then so as to not get a FOUC or similar.
1*new Date()turns the date object into an integer.