Is it possible to protect the source code of the page using only JS?
For example, block the item "Explore item" and "Source code" in the menu when you press RMB, block keys such as F12 , CTRL + S and others that allow you to view the source code.

  • No impossible. - andreymal
  • No Get over it. - user207618 pm
  • The only thing that can help a bit is obfuscation of the code. But it just complicates debugging, your perfect algorithms will still be available. - user207618
  • No, it’s impossible to hide what is being downloaded to the client in the clear) The only thing that can help php)) - Vladimir Alexandrov

1 answer 1

All actions you specify "protect" can not (perhaps even any). But even if it was possible - you can use traffic analyzers (sniffers), with which you can easily look at any code. For example, Charles or wireshark .

Ps. you need to understand that any html, css, js that hits the client cannot be protected from viewing, because it must be transmitted over the network and executed at the client, which means it can be viewed not only by the JS engine, but also by the person: D

Pps. but to protect the code (js) - you can use obfuscators (at the same time they are minifiers): JSmin, Closure compiler, YUI Compressor. it’s impossible to protect css and html (although it is possible, of course, to minify it, but it’s in two seconds any IDE will fix the readable view.)

  • Transmitted over the network can be a cipher (SSL, for example). Another point is that you can not encrypt what should be done at the client, otherwise the meaning of the transfer is lost. - user207618