How to prevent Disqus from slowing down page load speed - ΩJr. Software Articles and Products

This information lives on a web page hosted at the following web address: 'https://omegajunior.globat.com/code/'.

A simple adjustment of their javascript code prevents pre-loading of their files, plus it increases compliance to the European Cookie Law.

A.E.Veltstra
Nov. 21, 2012

Road to Reduction
Put Disqus on hold and load it only after the reader presses an "accept" button, explicitly accepting the use of cookies and other storage methods, that perhaps can be used to track them.


Source code
This is the html5/js code we use here, at the OmegaJunior Consultancy and its subsidiaries.


<div class=pageComments>
<hr>
<p><strong>Page Comments</strong></p>
<div id="disqus_thread"><p class="cookiesDisqus">By activating and using the Disqus feedback service below, you agree to <a href="http://help.disqus.com/customer/portal/articles/466259-privacy-policy">their privacy policy</a>. If not, use e-mail.</p><form onsubmit="my.loadDisqus();return false;" class=formBlock><input class=cmd type=submit value="Activate"> <a href="http://disqus.com/" class="dsq-brlink">Page Comments powered by <span class="logo-disqus">Disqus</span>.</a></form></div>
<script>/* <![CDATA[ */
var disqus_shortname = "omegajunior";
// provide the following in the template, if necessary
// var disqus_url = "http://www.omegajunior.net/";
// var disqus_identifier = "/";
if (typeof my == "undefined") {
var my = ({});
}
my.loadDisqus = function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = 'http://omegajunior.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
};
/* ]]> */</script>
<noscript>Please enable javascript to view the <a href="http://disqus.com/?ref_noscript">Page Comments powered by Disqus.</a></noscript>
</div>

Obviously you'd need your own Disqus shortname and javascript source location to make this work for you.


What is Disqus?
Disqus is a 3rd-party page commenting system anyone can tack on to their web pages or blog articles. It relies on Javascript, which suits just fine as a preventative measure against blog spam.


What is the problem?
Disqus adds 100 - 200KB to every page, in the pre-2012 format. Plus, it adds quite a bit of time to "load" the page: the scripts need to render an entire discussion board interface on the fly, which they do rather speedy, but will result in page redraws nonetheless, and in wait times for stupid browsers.

We wish to boast speedy, light-weight web pages, and that means finding a solution wihout sacrificing functionality.


Tools for measuring
Part of your browser: Google Page Speed, Chrome Speed Tracer, Firefox Timeline, MSIE Network.
Online: www.gtmetrix.com, loads.in.

Need problem solving?

Talk to me. Let's meet for coffee or over lunch. Mail me at “omegajunior at protonmail dot com”.