Skip to content

Instantly share code, notes, and snippets.

@CaiJimmy
Last active April 29, 2024 08:43
Show Gist options
  • Save CaiJimmy/84dead2d2919af05fede to your computer and use it in GitHub Desktop.
Save CaiJimmy/84dead2d2919af05fede to your computer and use it in GitHub Desktop.
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