Skip to content

Instantly share code, notes, and snippets.

@simondahla
Created September 30, 2013 14:39
Show Gist options
  • Save simondahla/6764758 to your computer and use it in GitHub Desktop.
Save simondahla/6764758 to your computer and use it in GitHub Desktop.
var startTime;function loadJs(url, callback) {  var js = document.createElement('script');  js.async = true;  js.src = url;  var s = document.getElementsByTagName('script')[0];  js.onload = trackTimingCallback;  startTime = new Date().getTime();  s.parentNode.insertBefore(js, s);}function trackTimingCallback(event) {  var endTime = new Date().getTime();  var timeSpent = endTime - startTime;  ga('send', 'timing', 'jQuery', 'Load Library', timeSpent, 'Google CDN');  // Library has loaded. Now you can use it.};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment