Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:17:27+00:00 2026-05-24T03:17:27+00:00

Is it possible to hide the Javascript code from the html of a webpage,

  • 0

Is it possible to hide the Javascript code from the html of a webpage, when the source code is viewed through the browsers View Source feature?

I know it is possible to obfuscate the code, but I would prefer it being hidden from the view source feature.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:17:28+00:00Added an answer on May 24, 2026 at 3:17 am

    I’m not sure anyone else actually addressed your question directly which is code being viewed from the browser’s View Source command.

    As other have said, there is no way to protect JavaScript intended to run in a browser from a determined viewer. If the browser can run it, then any determined person can view/run it also.

    But, if you put your JavaScript in an external JavaScript file that is included with:

    <script type="text/javascript" src="http://mydomain.example/xxxx.js"></script>

    tags, then the JavaScript code won’t be immediately visible with the View Source command – only the script tag itself will be visible that way. That doesn’t mean that someone can’t just load that external JavaScript file to see it, but you did ask how to keep it out of the browser’s View Source command and this will do it.

    If you wanted to really make it more work to view the source, you would do all of the following:

    1. Put it in an external .js file.
    2. Obfuscate the file so that most native variable names are replaced with short versions, so that all unneeded whitespace is removed, so it can’t be read without further processing, etc…
    3. Dynamically include the .js file by programmatically adding script tags (like Google Analytics does). This will make it even more difficult to get to the source code from the View Source command as there will be no easy link to click on there.
    4. Put as much interesting logic that you want to protect on the server that you retrieve via AJAX calls rather than do local processing.

    With all that said, I think you should focus on performance, reliability and making your app great. If you absolutely have to protect some algorithm, put it on the server, but other than that, compete on being the best at what you do, not by having secrets. That’s ultimately how success works on the web anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From my understanding, JavaScript code, because it is client-side, is not hidden to the
Possible Duplicate: Use same div to toggle different parts of the page Hello I
How do I hide my private API keys in/for my webOS - Enyo based
I'm trying to make it possible to reach certain tabs in the page by
I have a variable itemid (which is the id of an element) which I
Please let me ask something. I just confused for what is the difference of
How to show a next button when click on a checkbox and it should
Have you noticed that every 10 questions on this site is about jQuery? Anyway...
if I have a page called content page: <body > <p id=part1>Tread ... inch.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.