The discussion revolves around a theme component created by pfaffman to hide admins from the about page in Discourse. The component uses JavaScript to achieve this and pfaffman is concerned about potential performance issues due to the onPageChange event.
However, merefield reassures pfaffman that the extra JavaScript processing is negligible compared to the overall amount of JavaScript running on Discourse.
Heliosurge expresses interest in the component and suggests it could be useful for moderators as well. pfaffman confirms that the component is a theme component and provides a link to the GitHub repository, with plans to create a proper theme page in the future. Heliosurge is content to wait for the official rollout.
I’m wanting to remove my user from the about page of some sites I manage. I’m not the one who’s going to delete your account, or anything else. . .
One way is this:
But a plugin seems a bit heavy-handed these days, so I have a theme component that does this:
import { withPluginApi } from "discourse/lib/plugin-api";
const hidden_admins = settings.hidden_admins.split("|");
const PLUGIN_ID = "hide-admins";
export default {
name: "theme-javascript-initializer",
initialize() {
withPluginApi("0.8.30", (api) => {
api.onPageChange((url) => {
if (url != "/about") {
return;
}
for (const admin of hidden_admins) {
var element = document.querySelector(`[data-username=${admin}]`);
if (element === null) {
break;
}
element.classList.add("hide-me");
}
});
});
},
};
Is that stupid for some reason? Does that onPageChange cost very much? The plugin would affect only the about serializer, this does a check on every page change. Is that bad?
There was a topic about just this issue lately that just hard-coded the user in the CSS. Would having just a single CSS in a theme that just did:
That’s mostly what I thought, but I very much appreciate your confirmation. I’ll see about prettying this thing up a bit and making it public and then writing tooling to automate adding it to some sites.