Hello Gareth,
Saying that you dislike jQuery is the first thing that came to mind, because several people do. I was not getting personal with you, I was just trying to figure out why you say my code is horrible and dangerous.
I'll try again, no offense. If I understood correctly, you are the author of themes and many other plugins. You are certainly an excellent programmer. According to you, my code is horrible and dangerous because it could lead to version conflicts and other problems. I must admit that from your point of view as a programmer, you are absolutely right. A good programmer wants to avoid these kinds of problems.
Your turn to try to understand why I proposed my solution. I am a user, not a programmer, just a teacher in a school where there are currently 260 teachers. All Moodle courses are on a site administered by the IT department. If I want the General section not to appear on the course pages, I have to make the request to the IT department who will certainly refuse to modify the PHP code because this change would affect all the courses and other teachers could certainly not agree to this change. In the case that concerns us, there is a plugin that meets the request perfectly, but this is far from always the case. My request to the IT department to install the plugin could be accepted or not. Chances are it wouldn't, because the IT department would be too busy or they wouldn't consider my request justified.
Again nothing personal, but it seems that many programmers don't fully understand user needs. It looks like they think their software is perfect and it stops there. But I, who am still not an idiot (I have a doctorate in engineering from a well-recognized university and am a professor in a major engineering school), I would still like the General section not to appear on all the main course pages.
So I use a simple little JavaScript that does the job. That's all. And from experience, with the Boost theme, this kind of script, with the call to jQuery, works 100% of the time and does not cause any problems. It could be that in some cases, for example with another theme, this kind of script causes a problem. However, in reality, the risk is surely very low since no problem has ever been reported.
So, for you my code is horrible and dangerous. I agree. But for me it is great, very useful and effective. It works perfectly and causes absolutely no problems. And I hope it can help other teachers in the same situation as me.
Front-end solutions using JavaScript and the jQuery library are great workarounds for users when better solutions simply don't exist or aren't accessible. Obviously, they are not perfect and have a very significant risk of about 0% of causing problems.