venkatachalam
venkatachalam

Reputation: 102439

How to hide the 'script' HTML tag?

I am using HTML, and I'd like to hide the script tag from the user's view. When the user views the page source, the definitions should not appear. How do I accomplish this?

Example

<script type="text/javascript" src="My1.js"></script>
<script type="text/javascript" src="My2.js"></script>
<script type="text/javascript" src="jquery.js"></script>

I'd like to hide the definitions, any idea?

Upvotes: 1

Views: 11601

Answers (5)

Arta Seyzed
Arta Seyzed

Reputation: 37

In my last answer I misunderstood what you meant by hiding the code.

Well as our other friends said there is no way to hide Scripts from source code.

But if you are afraid of people who want to steal your codes you can simply code your javascript instead of hiding it.

If you need a tool to code your Javascript you can use: Shell Tool Online

And feel safe to add your scripts. If anyone try to copy your scripts, they will get nothing.

I hope it helps.

Upvotes: -1

Bjorn
Bjorn

Reputation: 71950

You cannot hide HTML. If you want a closed-source solution, use a proprietary format, such as Flash or Flex.

You can, however, obfuscate your JavaScript code (you should shrinkwrap or minify it anyhow) which makes reading it harder.

Upvotes: 15

Hollister
Hollister

Reputation: 3918

You could also write script directly into the DOM. This also does not eliminate it (and the script to write the script would be there), but the user would have to use a DOM inspector (e.g. Firebug) to see it; it wouldn't be visible via 'view source'.

As others have said, this is just obfuscation, and simply kicks the problem down the road.

Upvotes: 1

Ian P
Ian P

Reputation: 12993

It reads to me like he's wanting to completely eliminate it, not obfuscate it.

With that said, option #2 is to not use includes, and put obfuscated javascript in his HTML.

Upvotes: 0

Ian P
Ian P

Reputation: 12993

You can limit it to one script tag by making an include file that references the other scripts..

Other than that, no.

Upvotes: 3

Related Questions