-2

I see some websites allow users download our source include html file, css file, js file ... and almost. I don't want to do this for my website. What should I do? Thank for wathching!

P/S: If you can, please show me this approach with Zend. I'm using Zend 1.9.6.

Killer Whale
  • 87
  • 2
  • 12
  • 1
    Are you aware of how the Internet and web pages work? **Every single resource** required for a page is downloaded by *every single visitor* ('s web browser)!! – Jonathon Reinhart Jun 01 '13 at 10:10
  • I see but I don't want user download my source by tool -> save page as (chrome browser) or something technical like this. – Killer Whale Jun 01 '13 at 10:14
  • You can't avoid that. No matter what, the web browser must download the HTML, and typically cache it to disk. You could somehow ask a browser to disallow that, but there's nothing stopping me from using a different browser or performing a raw TCP session and saving the file myself. – Jonathon Reinhart Jun 01 '13 at 10:16
  • I saw! Once again, thanks..... – Killer Whale Jun 01 '13 at 10:35

4 Answers4

2

You cannot restrict the download of resources. The browser needs to download them in order to process them, if you restrict them from being downloaded the browser wont be able to access them as well.

php_nub_qq
  • 15,199
  • 21
  • 74
  • 144
2

That is impossible. The browser need the source code to display your site, in the same way you can't prevent the user to download an image if you show it to them. The best you can achieve is obfuscate your CSS and Javascript to a hard to read scrambled code, using YUICompressor, for example. But someone determined will always be able to decipher your code logic...

rixo
  • 23,815
  • 4
  • 63
  • 68
2

As said its impossible to hide js or css files but what you can do is minify(compress) them which will make it harder to interpret by user and making your site load faster at the same time .

Check this implementation of minfy library with ZF , it provides css,js view helpers to automate the compression .

http://hobodave.com/2010/01/17/bundle-phu-compress-your-js-css-in-zend-framework/

Mr Coder
  • 8,169
  • 5
  • 45
  • 74
0

If their browser can't read your HTML, how can it display your page?

They won't be able to read your PHP (assuming that your server is set up to parse PHP correctly), but they will always be able to read the HTML output.

Glitch Desire
  • 14,632
  • 7
  • 43
  • 55