You don't need a framework like React but you should try to implement modules that are explicit about their dependencies and use local state as much as possible.
For example the upvote could be implemented like this:
function renderUpvote(container, showNotification) {
$("<button>").appendTo(container).on("click", () => $.ajax( ...
result => showNotification( result ))
}
Now the notification action is passed in from a parent component. It's easy to trace where it comes from. You can also declare local variables in this function and have confidence that they will only be manipulated by callbacks within the module. This is how I wrote frontend code before React came out.