What's the fastest and easiest way to add a persistent javascript file or snippet

I’m a total noob and have just been granted admin rights to a discourse instance. I’d like to run a jQuery snippet on page load sitewide.
What is the easiest and fastest way for me to do that? I’m a web developer, so I know my HMLT, CSS, javascript+jQuery, PHP. But other than that I have no clue about Discourse (I’ve seen it uses ruby and other stuff that I’m not familiar with) and also don’t want to dive to deep into Discourse just for this.
I just need the fastest way.

Edit theme or create a component through the UI: Beginner's guide to using Discourse Themes
Also Developer’s guide to Discourse Themes

2 Likes

If I try to edit the theme I get a warning that my changes will be overwritten at the next theme update as this is an external theme.
I’m familiar with wordpress and what i’d do there would be to get a hello world plugin and renamed it and hack it so it does what I want then upload it and activate it.

Is there something like that in Discourse? A downloadable boilerplate component? Do I have to install a discourse instance and generate a component using commands, as that’s not something I’m looking forward to.

As I said, I’m looking for a very fast solution, I can’t study Discourse in detail right now.

I really hope I don’t come across as entitled or something like that. I was hoping for a quick solution instead of a RTFM. If that’s not how this community works, I understand and accept that.

As I said, the fastest solution is to create a component. You can create one in few clicks with the UI: Developer’s guide to Discourse Themes You can follow that but instead of importing, you create a “new” one. Then, once component is created, you can edit it to add HTML/CSS/JS.

I don’t have the time to make screenshot, and the guide already shows you what you need… You don’t need to read everything, you can be done in less than one minute.

4 Likes

Hey, I see now. I was looking for a button to create a new component. I didn’t realise I needed to click Install first.
Thanks, this should get me up and running.

[Update]
It worked well and painless. I was able to create a new component, add small script snippets to head and body and activate the component for all available themes.

1 Like