digital-analytics-program / gov-wide-code

Provides a set of javascript files and documentation to implement web analytics on US federal websites
http://www.digital.gov/dap
102 stars 54 forks source link

Load with async #41

Closed joewiz closed 8 years ago

joewiz commented 8 years ago

DAP's recommended script tag lacks an async attribute:

<!-- We participate in the US government's analytics program. See the data at analytics.usa.gov. -->
<script language="javascript" src="https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=AGENCY" id="_fed_an_ua_tag"></script>

Is it acceptable to add this attribute? The purpose is to eliminate the hit to page load times on our site due to blocking during DNS load time. DNS lookup times for dap.digitalgov.gov are typically 30ms but we've seen them regularly hit 100ms, even 200ms.

tdlowden commented 8 years ago

Hi @joewiz! Thanks for bringing this to our attention. We're currently working on a new code version and when we release it, we'll be changing the documentation to suggest adding the async attribute.

line-o commented 8 years ago

Does this mean we can use it already and the documentation is not up to date or should we wait for the new code version?

SamBronson commented 8 years ago

Sorry to speak out of turn, but if you are using a tag management system, like GTM, the async attribute is not necessary.

tdlowden commented 8 years ago

I am under the impression that our current code doesn't yet support async if using our script tag directly in html, but I'm double checking now.

tdlowden commented 8 years ago

@joewiz @line-o confirmed that the current version does not support the async attribute. But within a few weeks, the v3.0 code should be available, which will load asynchronously the the async attribute.

line-o commented 8 years ago

@tdlowden OK, thank you very much.

joewiz commented 8 years ago

@tdlowden Yes, thank you!

konklone commented 8 years ago

There's an open issue (well, PR) with some discussion of this exact issue: https://github.com/digital-analytics-program/gov-wide-code/pull/28

tdlowden commented 8 years ago

This option now available in v3.1! Closing... finally.

joewiz commented 8 years ago

Great news! We'll put it to use. Thanks for this improvement and for letting us know.

tdlowden commented 8 years ago

Thanks for bringing it to our attention! Sorry it took so long to get this version out.