-1

when I have the tag <script> anywhere on the page html, is it javascript client side.

Could you tell for the followong cases, is it server side or client side?That is, does it runs in a browser or not?

1)

<form name="myform" action="" method="get">
  <input type="text" name="s1" value="">
  <input type="button" name="s2" value="" onClick="myFunc(this.form)">
</form>
<form action="exemple.com">
(document).bindHandlers({
    paintGreen: function() { $(this).css("background","green"); }, 
    paintRed:   function() { $(this).css("background","red");   }, 
});
<button id="btnPaint" data-click="paintGreen" data-focusout="paintRed">Paint Town</button>
formObject.action = "exemple.com"
form.submit()
a k
  • 11
  • 2
  • 1
    Anything using ` –  May 18 '21 at 09:50
  • If it runs in a browser, it's client-side, if not (Node.js), it's server-side. – Jeremy Thille May 18 '21 at 09:52
  • I don't think the duplicate is a good target (because it is about passing data between scripts running on the client and the server, not identifying what code runs where). The question should still be closed for lack of focus though. – Quentin May 18 '21 at 09:57

1 Answers1

0

Server-side JavaScript refers to the use of Node.js. Any JavaScript file loaded via the <script> tag in HTML is executed client-side.

Siddharth
  • 450
  • 4
  • 10
  • There are plenty of [non-node.js based server side JS implementations](https://en.wikipedia.org/wiki/List_of_server-side_JavaScript_implementations) even if they are less common. – Quentin May 18 '21 at 09:55
  • While JS loaded into a script element is executed client side, it could be loaded from a URL where the JS is generated server side, and client side JS can be inserted into an HTML page through mechanisms other than ` – Quentin May 18 '21 at 09:55
  • This answer doesn't really address most of the question. – Quentin May 18 '21 at 09:56
  • Yes Node.js is lot more common than anything else. Even if the JS is generated server-side, the execution takes place client-side, so it is still client-side code. Yes there are other ways to insert client-side JS into HTML page, but that is quite beside the point. – Siddharth May 18 '21 at 10:00
  • Given that some of the examples in the question insert client-side JS using those other ways it is right in the middle of the point. – Quentin May 18 '21 at 10:01
  • Thank you. Do you know any site where a beginner can ask simple questions like that, please? – a k May 18 '21 at 10:32