Now that JavaScript libraries such as jQuery are more popular than ever, .js files are starting to contain more and more site logic. How and where does it extract data / information, how is this information processed, etc. This is not necessarily bad, but I wonder to what extent this could be a security issue.
Of course, the real data processing is still going on in the backend using PHP or some other language, and it is important that you do not do anything unnecessary at this point. But just by looking at the .js site (which depends heavily on, for example, jQuery), he will say that the person can be bigger than you, as the developer would like. Moreover, each browser currently comes with a fairly extensive web development environment or add-in. Even for beginners manipulating the DOM, this is no longer a big deal. And as soon as you find out what code is and how you can influence it by editing the DOM, the fun begins.
So my main problems are:
I donโt want everyone to be able to look at the .js file and see exactly (or rather: for the most part) how my site, web application or CMS works - what is there, what does it do, how does it do it, etc. .
I'm worried that by โrevealingโ this information, people who are much smarter than I figure out how to manipulate the DOM to influence the JavaScript functions that they now know use the site, possibly bypassing which I implemented (and therefore mistakenly assumed they were good enough).
I already use different .js files for different parts, for example. web application. But there are always things that should be available around the world, and sometimes it contains more than I would like to be public. And since all this is โthereโ, who said that they cannot find these other files anyway.
I sometimes see a huge piece of JavaScript without line breaks and all that. Like compact jQuery files. I am sure there are applications or tricks to convert your regular .js file into one long line. But if this can be done, is it not so easy to return it to something more readable (which makes it pointless except save space)?
Finally, I was thinking about whether it is possible to detect that the request for the .js file comes from the site itself (by including the script in the HTML) instead of directly loading it. Maybe by blocking the latter, for example, Apache ModRewrite, it is possible to use the .js file in HTML, but when someone tries to access it, it is blocked.
What do you think about this? Am I overreacting? Should I split my JS as much as possible or just spend more time triple checking the backend of scripts and include more checks to prevent harm? Or are there some best practices for limiting the exposure of JavaScripts and all the information they contain?