TypeError: Discourse._registerPluginCode is not a function

Thanks @vinothkannans for getting back and for pointing us to @sam’s comment. After following this to JavaScript not loading on certain pages and drilling down a bit further we would like to share our findings.

While the origin of this pretty much void object pretending to be a real Discourse instance

const Discourse = {
  SiteSettings: {}
}

is yet unknown, it will easily sneak through some safeguards the Discourse plugin loader had put into place, so

would obviously be completely clueless about this and will just attempt to run the plugin registration right away as if nothing happened, ultimately croaking there.