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

4

2 回答 2

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 .

于 2012-06-19T17:37:54.693 回答
-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.

于 2012-06-19T16:11:43.517 回答