-
-
Save livingston/382098 to your computer and use it in GitHub Desktop.
Optimized Script for loading User Voice Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Optimized Script for loading User Voice Script | |
* Based on idea by kangax @ http://gist.github.com/381634 | |
*/ | |
var uservoiceOptions = { | |
/* ... */ | |
}; | |
//Using `self` rather than `window` to prevent cross-domain issues when used in iframe | |
self.onload = (function (w, d, t) { | |
var _loadUserVoice = function () { | |
var s = d.getElementsByTagName(t)[0], | |
UV = d.createElement(t); | |
UV.async = !0; | |
UV.src = '//cdn.uservoice.com/javascripts/widgets/tab.js'; | |
s.parentNode.insertBefore(UV, s); | |
}, original = w.onload; | |
if(typeof original === 'function') { | |
return function () { | |
original(); | |
_loadUserVoice(); | |
}; | |
} | |
return _loadUserVoice; | |
}(self, document, 'script')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment