4 ms·
put the script at the bottom of the page I never understood why onload and all the frameworks implementing domloaded exist, script tags generally should go at
by daleharvey 17y ago
put the script at the bottom of the page
I never understood why onload and all the frameworks implementing domloaded exist, script tags generally should go at the end anyway, and there is no problems with dom availability.
- 124816 17y agoThis is fine, if you're OK with missing bounces. If the page takes a long time to load, or hangs, then it's likely the user will close the window before the script runs.
- enomar 17y agoI don't think he was necessarily suggesting putting GA at the bottom of the page. I read this as, "put the DOM ready detection" at the end of the page.
- enomar 17y agoWhen you're writing a third party script you don't have control over where in the page someone will put it. Having code to detect DOM ready is useful in these cases.