hide code

  • Thread starter Fernando Fernández
  • Start date
F

Fernando Fernández

Hi people :))

I am Fernando and I have made a web application with HTML and JavaScript.
Now I would like to hide the source code, or at least my JavaScript source
code. Is it possible? is there a method for doing it?

Thanks you from Palma de Mallorca, Spain
Fernando
 
D

DU

Fernando said:
Hi people :))

I am Fernando and I have made a web application with HTML and JavaScript.
Now I would like to hide the source code, or at least my JavaScript source
code. Is it possible? is there a method for doing it?

Thanks you from Palma de Mallorca, Spain
Fernando

This is actually the first question answered in this newsgroup FAQ:
http://jibbering.com/faq/#FAQ4_1

The general rule is that it is impossible to hide a code that must be
parsed and executed and/or rendered on a visitor's system.

DU
 
E

Enzo

Hola Fernando,

yo me encontraba con el mismo problema
para ocultar el código, pero como te han
comentado antes es imposible, ya que
siempre está accesible en el cliente.
Yo había probado crearlo con php y luego
borrarlo en el server con 'unlink', pero
la copia del js ya estaba en el temporal
del cliente.

La única opción es la ofuscación del mismo,
quitando espacios en blanco, p.ej.

Saludos desde Manresa,

Enzo
 
F

Fernando Fernández

Qué sorpresa encontrarse a alguien de habla hispana :)

Yo estaba haciendo cosas como guardar el código JavaScript en ficheros .JS
De este modo el código no se ve directamente, pero sigue viéndose el fichero
donde se esconde, porque siguen viendo la línea <...SRC="mi_fichero.js"...>

En fin, muchas gracias por vuestra ayuda.
Un saludo desde Palma de Mallorca
Fernando
 
F

Fernando Fernández

Thanks you for your fast answer.

Actually I write my JavaScript code in JS files. In this way I have
separated my HTML file and my JS file. I don't know how much difficult is
now get my source code for the person who wants do it... but at least the
code is not in the same HTML file... is it a good idea?

Thanks you again
From Palma de Mallorca, Spain
Fernando
 
E

Enzo

Ahora nos pasará la caballería por encima,
por no escribir en inglés ... ;-)

Un saludo,

Enzo
 
R

Random

Fernando said:
Thanks you for your fast answer.

Actually I write my JavaScript code in JS files. In this way I have
separated my HTML file and my JS file. I don't know how much difficult is
now get my source code for the person who wants do it... but at least the
code is not in the same HTML file... is it a good idea?

Thanks you again
From Palma de Mallorca, Spain
Fernando


It's a good idea in most cases, for various reasons (it modularises and
compartmentalises everything, keeping the JS with th JS and HTML with
the HTML, and encourages the programmer to keep things encapsulated and
portable, et cetera), but it doesn't obfuscate your code.

If someone looks at the code of the web page (which they will do if
they want to see your JS code, right?), they will immediately see the
<script src=... /> tag and know where to get your code.

There is no way to protect open source code from theft. Don't even
bother trying-- it just makes it harder for you to manage your own code.
 
J

jTag

You can hide JS files by combining serverside script and javascript.

Ex:
In HTML file:
...
<% Session("javascript") = True %>
<script type="text/javascript" src="javascript.asp"></script>
...


In the javascript.asp file:
<%
If Session("javascript") Then
Response.ContentType = "application/x-javascript"
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Session("javascript") = False
%>
//script goes here
<% else %>
This script is hidden :)
<% end if %>

.............

You can still get the script but it's not that easy.


:: jTag
 
R

Randy Webb

jTag said the following on 11/10/2005 7:10 PM:
You can hide JS files by combining serverside script and javascript.

No you can't.
Ex:
In HTML file:
...
<% Session("javascript") = True %>
<script type="text/javascript" src="javascript.asp"></script>
...

Look in cache, open javascript.asp. There is your script.
In the javascript.asp file:
<%
If Session("javascript") Then
Response.ContentType = "application/x-javascript"
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
Session("javascript") = False
%>
//script goes here
<% else %>
This script is hidden :)

No it isn't, you just think it is.
<% end if %>

.............

You can still get the script but it's not that easy.

It's not "easy", it is trivially easy.
 
E

Evertjan.

Randy Webb wrote on 11 nov 2005 in comp.lang.javascript:
It's not "easy", it is trivially easy.

Randy, let's help them [out of their dream]:

Look for the src string with view source,
then go back to the original file,
where you are still in session!,
and type in the browser addressbar:

javascript:eek:pen('javascript.asp')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top