Since Discourse is an SPA, relying on the document “DOMContentLoaded” won’t be very helpful, since the document DOM is always “loaded” but the elements can be missing. Instead you’ll want to use Components as @merefield mentioned, or something like this: How do you force a script to refire on every page load in Discourse? - #5 by simon. This way every time the page changes, your code can check for the element you’re trying to change.
Alteras
(Steven Chang)
4
Related topics
| 글 | 댓글 | 조회수 | 활동 | |
|---|---|---|---|---|
| Custom javascript gets only applied after refresh, creating categories for location plugin | 9 | 128 | 8월 13, 2025 | |
| How to add Javascript to Footer Of Posts? | 3 | 935 | 10월 10, 2021 | |
| A better way to implement custom jQuery code? | 3 | 553 | 2월 18, 2021 | |
| Executing js after DOM loaded | 6 | 3740 | 11월 30, 2018 | |
| How do you force a script to refire on every page load in Discourse? | 38 | 21381 | 3월 12, 2020 |