Advice on a hide admin from about page theme component--is this going to slow things down?

AI-generated summary

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:

.about-page div[data-username="pfaffman"] {
  display: none !important;
}

be better? It wouldn’t be useful for anyone other than me, which is why I sort of like this theme component idea.

So for every page turn except “about” you are processing ~two lines of extra javascript?

No I don’t think that is bad given the enormous amount of javascript that runs all the time on Discourse :slight_smile:

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.

Thanks very much.

So Jay would this be a plugin to install or a Theme-component?

I think this could be handy to even extend functionality to even Mods. For some use cases.

This is a theme component. I’m still cleaning it up a bit. I’ll make a proper theme page for it on the next while, but you can see GitHub - literatecomputing/discourse-hide-admins-about: Theme component to hide some admin users from about page · GitHub if you’re excited to try it out.

That is quite cool. I am content though to wait for your official roll out.