6

Here is a part of the Disqus's "universal code":

var disqus_config = function () {
    this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
    this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

What I don't undestand is how Disqus handle this function, because page is undefined, so we cannot access to identifier or url. I have tested several examples:

disqus_config();
console.log(disqus_config.page);
var a = new disqus_config();

But I still don't understand how Disqus handle this undefined element.

gokan
  • 1,028
  • 1
  • 14
  • 30

1 Answers1

2

As far as I see, in the embed.js code it's something like this:

var _config = window.disqus_config;
window.disqus_config = function () {
    if (_config) _config.call(this);
    // Other stuff here....
};

So, before replacing it, disqus checks if it exists then runs it within its own scope.

Ciprian Mocanu
  • 2,166
  • 3
  • 25
  • 44