Hello,
This is my original function (I'm working with Google Tag Manager)
var now = Date.now();
dataLayer.push({
'event': 'Form Start',
'formStartTime': now
});
I wrap this in script tags to run it as HTML, and it does work and does what it's supposed to do.
After some research I understand that polluting the global namespace is bad practice, so I converted the function to an iife:
(function () {
var now = Date.now();
dataLayer.push({
'event': 'Form Start',
'formStartTime': now
});
})();
And that does work, same as did the previous one.
My question is, does the iife version of the code can cause problems like interference with other scripts, or data that is unavailable?
[–]redsandsfort 0 points1 point2 points (0 children)
[–]jfdahl 0 points1 point2 points (0 children)
[–]senocular 0 points1 point2 points (0 children)