Custom javascript and canvas element

Basic question:
Is it possible to add custom javascript code to a page / topic?

For example if I want a canvas element 200x200 and to be able to draw lines on it ,just using vanilla js, ctx.lineTo() etc

I’ve seen this done on Nodebb and the method there would be to add a Widget, and then HTML / js can be dropped in there. Not sure how the equivalent works on Discourse?