# How to protect my web app (scripts, models)?

**URL:** <https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165>\
**Category:** Help & Support\
**Created:** [June 17, 2019, 4:04am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165 "2019-06-17T04:04:18Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![SunnyChow](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/sunnychow/32/20351_2.png) [@SunnyChow](https://forum.playcanvas.com/u/SunnyChow)\
**Post date:** [June 17, 2019, 4:04am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/1 "2019-06-17T04:04:18Z")

</div>

For scripts, i know there is something like JScompress to make the scripts smaller and unreadable. but how do i do it with Playcanvas? I use Chrome inspect panel to read the downloads, and the scripts are quite readable. Do i have to download the build and compress it myself?

For models, i use Chrome to read the downloads and find out the 3d models are readable JSON, which mean it’s very easy to convert it to any 3d format. Is there any way to make it more secure? How does sketchfab do it?

Also, is it possible to protect the textures instead of sending it as native image files?

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [June 17, 2019, 8:25am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/2 "2019-06-17T08:25:41Z")

</div>

> [@SunnyChow](#):
>
> Do i have to download the build and compress it myself?

Yep. The paid plans allow exporting the build and you can do post build step to compress/obfuscate the JS code.

> [@SunnyChow](#):
>
> For models, i use Chrome to read the downloads and find out the 3d models are readable JSON, which mean it’s very easy to convert it to any 3d format. Is there any way to make it more secure?

> [@SunnyChow](#):
>
> Also, is it possible to protect the textures instead of sending it as native image files?

You are pretty much sending everything over internet to the clients’ machine so it will be readable by the client in some form.

You have to think about protection as Internet content vs a typical game. So the usual copyright, trademark etc. Trying to protect the content is a losing battle to be honest.

---

<div class="post-metadata">

**Author:** ![will](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/will/32/4560_2.png) [@will](https://forum.playcanvas.com/u/will)\
**Post date:** [June 18, 2019, 12:50am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/3 "2019-06-18T00:50:09Z")

</div>

It’s possible to extract the artwork from just about any native game.

- [Flappy Bird](https://playcanv.as/p/2OlkUaxF/)
- [Titanfall](https://playcanv.as/p/29NDUe2T/)
- [Doom 3](https://playcanv.as/p/iCL6sxgF/)
- [Call of Duty: Black Ops III](https://playcanv.as/p/XPWoTZ4F/)

Sketchfab uses [OSGJS](http://osgjs.org/) as its rendering engine. Presumably, the models are in the file format of the engine. It’s not encrypted and I doubt there’s any obfuscation. The nature of the web today is that there is no DRM that can be applied to any web content. There’s always a mechanism to access the downloaded data somehow.

If you don’t want to send JPGs/PNGs to the client, just use the [Editor’s ability to compress images to GPU supported formats](https://developer.playcanvas.com/en/user-manual/assets/textures/#texture-compression). You should probably be doing that anyway to use less video memory for your textures.

Lastly, the Editor does minify and obfuscate your game scripts. Just ensure when you publish, you check this box:

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/6/66c3e32b7871ce46d3a919e045489999bd4baa5b.jpeg)

---

<div class="post-metadata">

**Author:** ![SunnyChow](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/sunnychow/32/20351_2.png) [@SunnyChow](https://forum.playcanvas.com/u/SunnyChow)\
**Post date:** [June 18, 2019, 3:23am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/4 "2019-06-18T03:23:19Z")

</div>

i have tried “concatenate Scripts”, but my scripts in \_\_game-scripts.js are still very readable. i can just beautify it and copy it toanother project.

---

<div class="post-metadata">

**Author:** ![will](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/will/32/4560_2.png) [@will](https://forum.playcanvas.com/u/will)\
**Post date:** [June 18, 2019, 2:54pm UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/5 "2019-06-18T14:54:51Z")

</div>

That’s the best level of JavaScript obfuscation that can be achieved AFAIK. Unless you are aware of better alternatives?

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [June 18, 2019, 3:12pm UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/6 "2019-06-18T15:12:20Z")

</div>

I’ve been using [https://obfuscator.io/](https://obfuscator.io/) for a web page which really mangles the code and trips breakpoints if someone tries to look in devtools. Haven’t tried it with PlayCanvas code yet though so I have no idea if it works or impacts performance.

Code looks like this afterwards:

```javascript
function(){var _0x25f653={'cOINL':function(_0x390461,_0x43b144){return _0x390461===_0x43b144;},'GykCg':_0xf5244c[_0x58b8('0x17')]};var _0x39bdfd=!![];return function(_0x2f4a36,_0x5a7f2d){var _0xe6e76a=_0x39bdfd?function(){if(_0x5a7f2d){if(_0x25f653[_0x58b8('0x18')](_0x25f653[_0x58b8('0x19')],_0x25f653[_0x58b8('0x19')])){var _0x32b3c2=_0x5a7f2d[_0x58b8('0x1a')](_0x2f4a36,arguments);_0x5a7f2d=null;return _0x32b3c2;}else{if(_0x480577){console[_0x58b8('0x1b')](e);}}}}:function(){};_0x39bdfd=![];return _0xe6e76a;};}();(function(){if(_0xf5244c['PMIts']===_0xf5244c[_0x58b8('0x1c')]){d=ds[i];d[_0x58b8('0x1d')]['display']=displayValue;}else{_0xf5244c[_0x58b8('0x1e')](_0xf6199d,this,function(){var _0x4eb353=new RegExp(_0xf5244c[_0x58b8('0x1f')]);var _0x405e8b=new RegExp(_0xf5244c['PUUNL'],'i');var _0x2372d2=_0xf5244c[_0x58b8('0x20')](_0x1605ac,_0x58b8('0x21'));if(!_0x4eb353[_0x58b8('0x22')](_0xf5244c[_0x58b8('0x23')](_0x2372d2,_0xf5244c['hySTV']))||!_0x405e8b['test'](_0xf5244c[_0x58b8('0x23')](_0x2372d2,_0xf5244c[_0x58b8('0x24')]))){if(_0xf5244c[_0x58b8('0x25')]===_0xf5244c[_0x58b8('0x26')]){return-0x1;}else{_0xf5244c[_0x58b8('0x20')](_0x2372d2,'0');}}else{_0x1605ac();}})();}}());var _0x111c2a=function(){var _0x31490e={'WxboR':function(_0x9922d2,_0x4f545b){return _0xf5244c[_0x58b8('0x27')](_0x9922d2,_0x4f545b);},'yCWKZ':_0xf5244c[_0x58b8('0x28')],

```

---

<div class="post-metadata">

**Author:** ![SunnyChow](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/sunnychow/32/20351_2.png) [@SunnyChow](https://forum.playcanvas.com/u/SunnyChow)\
**Post date:** [June 21, 2019, 3:55am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/7 "2019-06-21T03:55:29Z")

</div>

Okay. Here is my conclusion after some more experiment.

The latest web browsers (chrome/firefox) seems avoiding NinjaRipper ripping the models. i can only get some useless fragments. But with an older firefox, i can rip the models through Ninja Ripper.It works perfectly with PlayCanvas, but for sketchfab, it can only get a messed up model. So I guess they have added some obfuscation,their model probably only works with correct shader.

---

<div class="post-metadata">

**Author:** ![RipcordDev](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/ripcorddev/32/22524_2.png) [@RipcordDev](https://forum.playcanvas.com/u/RipcordDev)\
**Post date:** [September 6, 2019, 2:58pm UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/8 "2019-09-06T14:58:29Z")

</div>

I just tried [obfuscator.io](http://obfuscator.io) on my own project and it works quite well. It’s a simple project at the moment so I haven’t noticed any performance impact. It’s possible that might change as the project grows, but so far so good.

Thanks for the suggestion!

---

<div class="post-metadata">

**Author:** ![Mal\_Duffin](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/mal_duffin/32/6794_2.png) [@Mal\_Duffin](https://forum.playcanvas.com/u/Mal_Duffin)\
**Post date:** [December 10, 2019, 8:42pm UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/10 "2019-12-10T20:42:59Z")

</div>

It would be great to have an obfuscation option for download.

I think I read somewhere that code published within the PlayCanvas site is obfuscated by default, it would be good to have the same obfuscation option here for the download option.

![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/3/360ce461da13a7f7b9e7395c7b0e142c2a329c59.png)

---

<div class="post-metadata">

**Author:** ![Mal\_Duffin](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/mal_duffin/32/6794_2.png) [@Mal\_Duffin](https://forum.playcanvas.com/u/Mal_Duffin)\
**Post date:** [December 10, 2019, 8:44pm UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/11 "2019-12-10T20:44:09Z")

</div>

> [@Code Protection](https://forum.playcanvas.com/t/code-protection/382/6):
>
> Yep. By default, your published apps now have minified/obfuscated code.

---

<div class="post-metadata">

**Author:** ![will](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/will/32/4560_2.png) [@will](https://forum.playcanvas.com/u/will)\
**Post date:** [December 11, 2019, 12:02am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/12 "2019-12-11T00:02:25Z")

</div>

I think the concatenate option does more than just concatenate and minify. Hey, @vaios, doesn’t it also obfuscate?

---

<div class="post-metadata">

**Author:** ![wturber](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/wturber/32/5173_2.png) [@wturber](https://forum.playcanvas.com/u/wturber)\
**Post date:** [December 11, 2019, 2:17am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/13 "2019-12-11T02:17:14Z")

</div>

I dunno. I’m no expert, but just today I wanted to make a simple modification to a script without doing the full publish. It was simply a matter of removing two // marks to un-remark a line … or so I thought.

Turns out that the remark was removed by the concatenation process. So, no big deal. I’ll just type it in manually. But hold on. The existing script seems to be breaking the rules about using a semicolon at the end of some lines. Hmmm… So I insert my line anyway and it broke a completely unrelated part of the app. So I just went ahead and made the simple change in editor and re-published and then went and looked to see what the change looked like in the final \_\_game-scripts.js. That’s when I noticed that _ **event.event.preventDefault** _ was now _ **t.event.preventDefault** _.

So the concatenation is also doing more than simply running all the lines together. Of course this doesn’t make it highly secure or even very secure. But it does mean somebody has to go to a fair bit of trouble to get your code and make it work.

---

<div class="post-metadata">

**Author:** ![vaios](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/vaios/32/4566_2.png) [@vaios](https://forum.playcanvas.com/u/vaios)\
**Post date:** [December 11, 2019, 5:37am UTC](https://forum.playcanvas.com/t/how-to-protect-my-web-app-scripts-models/10165/14 "2019-12-11T05:37:23Z")

</div>

> [@will](#):
>
> I think the concatenate option does more than just concatenate and minify. Hey, @vaios, doesn’t it also obfuscate?

It minifies and renames variables. That option is available whether you publish or download a build. We recently added the option to also generate source maps so you can debug a minified build more easily.
