This is a popular question among new Webmasters. You work hard and long hours coding your site to get it perfect, and you want to protect your secrets from would-be code stealers. But the Internet browsers don’t really help in the way of the “View Source” option. So can you hide your source? The real answer is, you can’t hide your HTML source and have it be practical. If you don’t believe that, then read on for some non-practical ways to hide your source.
There’s a couple of different ways you can hide your source from Internet thieves. One is to take a picture of every page on your site, turn them into a GIF or JPG, whichever you prefer, and use those in an image map for each page. That way, all you have is an image tag in your source. The average page will be about 110 KB per GIF/JPG, so your site will have a slightly more-than-average load time. However, your code is safe. One easy way to shorten the load time is to make your GIFs a maximum of 16 colors, though preferably 2 colors. This method is more effective if your audience is on a T1 or higher, because at 1.54 MBps, your page should only take about 5 seconds to load as compared to the 2-3 minutes for modem users.
If you don’t like to mess with graphic editors, try your hand at some JavaScript. A simple addition to the top of your Web page can stop HTML hijackers in their tracks. Here’s the code.
<script type="text/javascript"> window.close(); </script>
This simple code closes your Web page before they have a chance to view your source. They’ll have to be pretty quick to steal your secrets. Your users only have about 1/1000th of a second to look at your Web page, find out what it’s all about, and find a link to click for more information. However, your code is safe. This is very useful if your target audience is a group of speed readers with photographic memories and lightning quick hands.
If you aren’t too familiar with JavaScript, try encrypting your Web site using a simple search and replace on the HTML code in all of your pages. Replacing ‘a’ for ‘c’, ‘b’ for ‘x’, ‘c’ for ‘r’, and so on through the alphabet will take care of anyone even understanding your code, let alone stealing it and making it work. Make sure you make backups of your pages before hand, just in case you search and replace a wrong letter. This method has been known to change the content on your page and sometimes even render it useless, however your code is safe.
If you’re serving your pages with Perl, instead of sending your pages using the “print” command, try the “print_secure_hide_source” command. This will insure that none of your code is view-able on their browsers. On the downside, your users may not get the page you intended. This method has been known to return a page made by someone named Error and sometimes even a blank page. However, your code is safe.
Still, the easiest, most popular and most secure way to prevent this is to cut out the whole “posting to the Internet process.” There are some downsides to this. Namely that your Web site won’t actually be on the Web. But your code is safe.
If you haven’t yet realized the intentional sarcasm or bloated exaggeration of these solutions, YOU CAN’T HIDE YOUR SOURCE! That is, you can’t hide your code and still have an easy site to maintain and view. I’m sure there is some type of software out there that can, in a way, compile your Web pages, but that’s like buying a nuclear bomb shelter, 2 KM below the earth’s crust to save a house fly. It’s just not practical.
I’m sorry to say, but the World Wide Web is completely open source when it comes to HTML. It’s not a bad thing, just an attribute of the Internet. It’s a basic facet of Web design to learn from other peoples code. For example, how many times have you viewed someone else’s source to see how they did something? It’s what the whole Internet is about: free information. You might not realize it, but you can impress people with your code. By doing something on your Web site that looks amazing yet takes a small simple chunk of code to achieve, you gain respect from beginning Web designers looking for something to imitate.
And Remember, “Imitation is the best form of flattery.”