-1

In web page designing i am using css files and js files and these css files and javascript files are called in jsp page as follows:

   <script type="text/javascript" src="datepick.js"></script>  
  <link rel="stylesheet" type="text/css" href="datepick.css" />

If somebody views page source then he can know css files as well as js files, but how can i prevent it?

in index.jsp

 <html>
  <head>
    <script type="text/javascript" src="datepick.js"/>
   <link rel="stylesheet" type="text/css" href="datepick.css"/>
  </head>
  <body>
  ..............
  .............. 
  </body>
 </html>

If somebody views page source then immediately he can view datepick.css and datepick.js , which i do n't want. How can i prevent him from viewing these css and javascript files?

4 Answers 4

1

You cannot hide CSS or JS as the are client-side scripts. The best you can do is to obfuscate your JavaScript and compress your CSS.

0

You can't. You have to give the browser the CSS and JS so that it can parse them. Anything you give to the browser you also give to the user.

2
  • ok but @import... syntax can prevent user from viewing these files? Is there not any way to achieve it?
    – saroj
    May 3, 2012 at 5:43
  • No. It just means they have to get the file from the URL referenced by @import instead of (or as well as) one referenced by <link>
    – Quentin
    May 3, 2012 at 5:44
0

Short Answer: NO.
Whatever tricks may you used to hide your css and js, users can able to track it easily. Because there are lot of Developer tools available in the market. Better leave this idea for hiding your files...

0

In HTML, if you can see it, you can get it.

JS runs in web browser. JSP runs in JSP container.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.