Can I hide the javascript on my site?

I’m using Javascript to display some charts on a page. If you do a view source it shows all the data for each of the data points and it’s really kind of a mess. Is there a way to hide that or load it remotely so if you do view source you don’t see all of that stuff? Like save all of that in another file and then just call it rather than actually putting it all in the code.

Normally no, but I guess if you use node.js that would since it runs on the server. Never used it though.

EDIT – Or you could obfuscate it to make it harder to see.

minify your js and include it as an external file

Normally no, but I guess if you use node.js that would since it runs on the server. Never used it though.

EDIT – Or you could obfuscate it to make it harder to see.

I think he’s literally asking if it’s possible to serve JavaScript outside of inline HTML.

Yes, it is possible. Serve it in a .js file using <script src….>.

If your problem is that you need to populate the data for your charts dynamically based on dynamic data or some such, then pass variables to it using inline an script (or an external script that is preprocessed with PHP or some other server-side language so that it can set the variables). This might require some refactoring of your code. If I were doing it, I would use data-* attributes in my HTML because I don’t much care for having unnecessary scripts in my shit.

Frankly, I would tell you not to worry about it. This is mostly a cosmetic issue, and you already struggle too much with web development. First learn the important stuff, then you can sweat the small shit like this.