Skip to content

Instantly share code, notes, and snippets.

@kangax
Created April 28, 2010 01:50
Show Gist options
  • Save kangax/381634 to your computer and use it in GitHub Desktop.
Save kangax/381634 to your computer and use it in GitHub Desktop.
var uservoiceOptions = {
/* ... */
};
function _loadUserVoice() {
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js");
document.getElementsByTagName('head')[0].appendChild(s);
}
_loadSuper = window.onload;
window.onload = (typeof window.onload != 'function') ? _loadUserVoice : function() { _loadSuper(); _loadUserVoice(); };
@fearphage
Copy link

Is there a reason you are using window.onload instead of event listeners?

Also:
return (typeof original == 'function'
? function() {
original();
_loadUserVoice();
}
: _loadUserVoice
);

Less repetition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment