Is there a way to block or encrypt client script f...
# suitescript
d
Is there a way to block or encrypt client script file I don't want the user to see ? for example, I have a development with client script (the main script) and I don't want the user or other developers to see it content. I know for client script its pretty hard to that because its set on the browser but with all the experience in that forum did someone done something like this in the past?
a
it really depends how hard you want to try to hide it
technically you can't the client script HAS to load onto the browser and has to execute there
but you can obscure it if you choose
just do a find and a replace on all your variables names and call them a,b,c,d,e,f,g,h so its really difficult to understand what is actually happening
that's probably the simplest way... you can get WAY more creative though, but I wouldn't advise it
... other obvious things, simple things... delete all the comments and all the whitespace
e
There are obfuscation tools that do this for you
e.g. prettify.js, uglify.js
a
yeah i looked into those years ago and it wasn't 5 minutes to figure them out... find and replace and delete i can do in 5 mins 🙂
e
5 minutes - every time you publish a change to the client script.
a
yeah, ultimately my decision was... this is too much hassle 🙂 but if you need to do this consistently the time investment to figure out the obfuscation libraries is probably worth it.
you'd have to make it custom module too right? your base client script that is linked to the script record has to be NS readable
e
obfuscated code should still be readable by NS - it can't be encrypted or anything like that AFAIK
a
when you load the script into NS its gonna check for entry point names, if you've obfuscated those won't it throw an error?
e
Yes, entry point names would have to remain, but since object property names are part of the public signature of the module, a minifier shouldn't touch them. Definitely have to confirm that though
👍 1