0

I've written a small animation using node, express and the TweenJS library

Published on heroku for you to see here.

Currently when you click view source you get the following source.

Currently all of the javascript is handled client-side and script tags are called in the .jade files

To wrap my head around client side and server side javascript I would like to write this app so that the animation is executed server side. This should then stop viewers from being able to see the javascript source easily.

I have researched

module.exports

and looked at the method of calling

var animation = require('./animation.js');

for all of the required js files, but I am still stuck and dont quite get how executing the animation server side is possible.

Thanks for your time.

2 Answers 2

1

I'm afraid it doesn't work that way, you can't simply take a library that usually runs on a browser then expect it to run on node.js to manipulate the browser while your coding is "hidden" from the users.

Animation is inherently browser-based (access to DOM elements, manipulate their CSS etc)

You may imagine an animation setup where the calculations are done server side, with messages going from server to the browser to reposition and manipulate the DOM elements, but that's awfully inefficient and too much of a price to pay just to hide your animation code. In the end of the day you can also collect those messages to reverse engineer you animation.

Maybe client side JS obfuscation (minified & uglified) is a good middle!

Sign up to request clarification or add additional context in comments.

Comments

1

If you code executes server side how will it tell the browser what to display? You could do calculations server side and only send a stream of commands to a server side interpreter I suppose, or generate an animated gif, but at what cost?

You can minify, with something like the closure compiler or uglifyjs, your code before posting it to the server which would obscure it from casual observation.

1 Comment

Thanks, this is also a great answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.