First, this is how I'd normally load the comments.
The HTML markup:
<div id="comments">
<div id="disqus_thread">
<!-- Comments are dynamically loaded (via JS) here. -->
</div>
</div>
And the JavaScript code (custom.js):
$j=jQuery.noConflict();
$j(document).ready(function() {
$j('#displayComments');
var disqus_shortname = 'paulund';
$j.ajax({
type: "GET",
url: "http://" + disqus_shortname + ".disqus.com/embed.js",
dataType: "script",
cache: true
});
});
Now, coming to the point...
I'd like to load the comments, only when the user scrolls down to the comments section, i.e. div#comments.
Although not meant for this purpose, I've been told that Twitter Bootstrap's Scrollspy plugin could be used for doing this.
But I am not sure how.
(I've read the docs and tried various markups, but couldn't get it to work; and decided to start over from scratch.)
Here's a skeleton of the comments to test on: http://jsfiddle.net/MvTgk/ (and its respective demo)
PS: In case you don't have the time to write a full-fledged answer, please drop any hints/suggestions in the comments. I'll be happy to try them myself.
The ScrollSpy plugin is probably not what you should use.
According to the Bootstrap documentation "the ScrollSpy plugin is for automatically updating nav targets based on scroll position". Therefore, it should only be used for that.
Since you are using jQuery, you could use Sizzle to check when the comments box is visible.