Lets say I want to do the JS execution, like, processing Javascript Elements but on the Server rather than exposing the code(s) on the client JS file.
Something like, lets say:
window Object.window Object) in the backend by passing it to backend via Ajax, or whatever. So as an very simple examples (to do on the Backend JS Server):
window.location and do some codings related to it.window.document and do some codings related to it.So that means, (based on this simple example), i want to perform the parsing and whatever coding works, related to window.location & window.document Objects, in the backend (another) server. Just by passing this window Object to it. (Then return the already processed result back to the browser) So the user wont see what i am doing with this window object.
** Above is just a simple example. In fact, i want to pass some more complicated JS Objects and process at the backend.
That obvious point here is, i do not want my main JS processing codes to be exposed to the users.
Thanks
No, this is not possible as you describe.
JavaScript can run on the server, if your server has an engine to run the scripts. Node.js, which you tagged, is a good example of that.
But still, server and client are separated. The server cannot directly modify elements that are loaded into the client. The server feeds pages or other pieces of information to the client, which can be processed by the client.
So you could make an AJAX request to the server to perform some logic. This logic can be executed by PHP as well as Node.js, but when it comes to modifying the DOM, there is not much difference.
Node.js can be helpful, though. It supports a DOM as well, and I think you can even use jQuery, so an advantage over PHP is that you can do DOM manipulation in a similar way as on the client. It saves you a language to learn, but the client/server processing is still separated. You can't send an element with all its data and attached events to the server. You can send serialized objects at most.
Javascript is a client-side programming language and all code is interpreted at runtime by the browser on the client's machine. So the short answer is no.
For server-side code, use a server-side programming language such as PHP, ASP.NET or ColdFusion.