We have a CMS built on Java and it has Mozilla Rhino for the server side JS. At the moment the JS code base is small but growing. Before it is too late and code has become a horrible mess I want to introduce some best practices and coding style.
Obviously the name space control is pretty important. But how about other best practices - especially for Java programmers?
Server-side code can be written in any number of programming languages — examples of popular server-side web languages include PHP, Python, Ruby, C#, and JavaScript (NodeJS).
A server-side rendering benefit is the reduced dependency on JavaScript frameworks, resulting in a reduced page weight. Furthermore, JavaScript files can significantly add to the overall page weight. It's not uncommon for a suite of JavaScript libraries to be over 1 MB in size.
A server is generally going to be orders of magnitude more powerful than a client machine; and managed code is generally much faster than scripting. However - the client machine also usually has a lot of spare computational power that isn't being used, while the server could be running requests for thousands of users.
Here's some tips from the front lines:
var myns = myns || {};
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With