Hey,
I would check out Yoast's article on keyword density its a good article: https://yoast.com/keyword-density-in-yoast-seo/
Yoast mention "we encourage you to aim for a keyword density range of 0.5% to 2.5%, depending on a number of factors." which I would say is a good keyword density to aim for as well.
I am not really sure what you mean though in regards to hiding with Javascript? What are you talking about hiding? Could you please explain?
Cheers