1

We currently have a tool on our website that is created by JavaScript. The JavaScript is generated by Ruby via .js.erb and .html.erb files. The problem is that it's proprietary code and we'd like to at least be able to move it to a separate file so it's not directly viewable when using "View Source" and maybe include it in our bundles like a regular .js file.

Is there some way to intercept the rendering and redirect it elsewhere or something?

The closest I've come was this - Rails Javascript compression/minification on respond_to javascript response?

We did have it working server-side but it was too slow for our clients. We're using Rails 3.0

Community
  • 1
  • 1
Iko
  • 9
  • 4
  • 1
    Moving this JS into its own file will do very little to stop people seeing it. Typical browser dev tools make it very easy to look at a list of every script on the page, whether inline or loaded from another file. Anyone who wants to steal your client-side JS will steal it, there's no technical way to stop them. – jimw May 17 '12 at 12:43
  • True. But we can still minify and concatenate it to other files to make it harder to read without additional effort. – Iko May 17 '12 at 12:53
  • Indeed, there's certainly some value in that: minifying is worth doing if only for performance reasons. – jimw May 17 '12 at 15:18

2 Answers2

0

Try Javascript Obfuscation . Check this question on Stackoverflow for various ways to Obfuscate Javascript . How can I obfuscate (protect) JavaScript?

You can try YUI Compressor, Google Closure Compiler or UglifyJS .

The best way to prevent source code from being copied is to have most of the proprietary work done on the server side .

Community
  • 1
  • 1
geeky_monster
  • 8,672
  • 18
  • 55
  • 86
-1

So we didn't find any way to fully hide the Javascript. What we did end up doing was juggling a rather unfortunate number of variables and method stubs created via ruby and passed to more static javscript located in a separate file which gets minified. Not the most elegant of solutions but if you can follow the stub trail then I applaud you.

Iko
  • 9
  • 4