Permalink
Browse files

disqus comments lazyload

  • Loading branch information...
muratcorlu committed Apr 3, 2012
1 parent 2fd8d8d commit 381b1eb24292db1436d83deeeacdceca836e901c
@@ -1,4 +1,3 @@
{% include disqus.html %}
{% include facebook_like.html %}
{% include google_plus_one.html %}
{% include twitter_sharing.html %}

This file was deleted.

Oops, something went wrong.
@@ -23,6 +23,8 @@
<script src="{{ root_url }}/javascripts/modernizr-2.0.js"></script>
<script src="{{ root_url }}/javascripts/ender.js"></script>
<script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="{{ root_url }}/javascripts/jquery_disqus_lazyload.js" type="text/javascript"></script>
<link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml">
{% if page.feed_url %}
<link href="{{ root_url }}/{{ page.feed_url }}" rel="alternate" title="{{ page.title }} - {{site.title}}" type="application/atom+xml">
@@ -1 +1,6 @@
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{% comment %} Load script if disquss comments are enabled and `page.comments` is either empty (index) or set to true {% endcomment %}
{% if site.disqus_short_name and page.comments != false %}
<div id="disqus_thread" aria-live="polite" data-disqus-shortname="{{ site.disqus_short_name }}" data-disqus-identifier="{{ site.url }}{{ page.url }}" data-disqus-url="{{ site.url }}{{ page.url }}">
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
{% endif %}
@@ -26,8 +26,8 @@ <h1 class="entry-title">{% if site.titlecase %}{{ page.title | titlecase }}{% el
</article>
{% if site.disqus_short_name and page.comments == true %}
<section>
<h1>Comments</h1>
<div id="disqus_thread" aria-live="polite">{% include post/disqus_thread.html %}</div>
<h1>Comments</h1>
{% include post/disqus_thread.html %}
</section>
{% endif %}
</div>
@@ -29,7 +29,7 @@
{% if site.disqus_short_name and page.comments == true %}
<section>
<h1>Comments</h1>
<div id="disqus_thread" aria-live="polite">{% include post/disqus_thread.html %}</div>
{% include post/disqus_thread.html %}
</section>
{% endif %}
</div>
@@ -0,0 +1,36 @@
/**
* Load disqus comments when visitor scroll down page to comments
*
* @author: Murat Corlu
* @link: https://gist.github.com/gists/2290198
*/
$(function(){
var disqus_div = $("#disqus_thread");
if (disqus_div.size() > 0 ) {
var ds_loaded = false,
top = disqus_div.offset().top, // WHERE TO START LOADING
disqus_data = disqus_div.data();
function check(){
if ( !ds_loaded && $(window).scrollTop() + $(window).height() > top ) {
ds_loaded = true;
for (key in disqus_data) {
if (key.substr(0,6) == 'disqus') {
window['disqus_' + key.replace('disqus','').toLowerCase()] = disqus_data[key];
}
}
(function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = 'http://' + window.disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
}
}
$(window).scroll(check);
check();
}
});

0 comments on commit 381b1eb

Please sign in to comment.