I'm a beginner when it comes to Node and Express. I have a query regarding how to securely hide Javascript code on the backend. Currently, I am working with Node.js and Express. My goal is to prevent users from easily accessing the code through browser inspection. I have created a basic script and included the link in index.html
, within the head
tags, like so:
<script src ="/javascripts/test.js"></script>
. Everything seems to be functioning correctly.
Upon attempting to inspect the page using Google
, I noticed that the code can be easily viewed by anyone.
I suspect this is due to using test.js
on the frontend side of the browser. How can I incorporate it into the backend to ensure that the code remains secure? What steps should I take to achieve this? Could you please provide me with an explanation? Thank you
Just for reference, the script looks like this:
function myFunction() {
alert("I am an alert box!");
}
Additionally, here's how I implemented it on the HTML button:
<button onclick="myFunction()" type="button" class="btn btn-primary">Primary</button>