Javascript

Javascript

This website uses moderate doses of Javascript to give it some interactive behaviour. Javascript is routinely used in animations that can be stopped and started by the mouse.

  Javascript code can be put inside HTML files in < script > sections, but I prefer to put most of it in separate files for better separation of layout and functionality.

  These separate script files have an extension of *.js. I often give them the same name as the HTML file that they are associated with, so foo.js is associated with foo.html. There are also some auxiliary, second level script files with generic names, like menu.js or svg_tools.js.

  Since *.js files cannot be nested, I use the most simplistic of scoping rules : all the *.js files used by an HTML file are listed at the end of its < body >, in the order in which the scripts in the *.js files use each other.

  Please feel free to look inside these script files in your browser. Just type the name of any script file in the address bar and you can read that file.

communication between Javascript and HTML

Javascript and HTML talk to each other in very awkward ways. HTML cannot call Javascript functions directly. Instead, HTML marks some fields with "id=.." string name tags, which are then looked up by name in the Javascript running separately. Javascript sets the "innerHTML" fields of those HTML entities to display its output to the user.

  To me this feels like handing over something by throwing it on the floor, and having someone else pick it up. There were probably good reasons why it grew to be this way, but it does not look like something anyone would design in good conscience.

Javascript math

Javascript can do some pretty complex math. This is put to good use on this website, as discussed here.

Put that text directly here. Without "math.js", it is a much simpler story, and perhaps best centralized.