In general, using custom JS to interact with the DOM is not going to play well with Dash apps, as in the frontend, the app is a React app, which has it’s own virtual DOM.
You probably need to build the functionality you need into very lightweight Dash component, then you will have full access to whatever JS functions you want.