最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to hide the 'script' HTML tag? - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Jan 22, 2009 at 2:53 venkatachalamvenkatachalam 102k31 gold badges74 silver badges77 bronze badges 1
  • these things do not appear unless you see the source code...and hiding source code is not possible (you can reduce the code by doing most of the things in backend but you can't eliminate it) – Gaurav Commented Aug 7, 2013 at 14:25
Add a comment  | 

5 Answers 5

Reset to default 15

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.

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

Other than that, no.

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.

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.

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.

发布评论

评论列表(0)

  1. 暂无评论