Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disqus点击加载
<button id="load-disqus" onclick="disqus.load();">
加载Disqus
</button>
<div id="disqus_thread"></div>
var disqus = {
load : function disqus(){
var disqus_shortname = 'disqus';
if(typeof DISQUS !== 'object') {
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
$('#load-disqus').remove(); ///加载后移除按钮
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment