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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With