views:

35

answers:

3

I want to pre-escape part of my javascript code and then include it in my page in the form of eval(unescape([code])). The reason is to hide something from spiders. would I be sacrificing performance? does any body have a better suggestion.

Also found this obfuscator: http://javascriptobfuscator.com/default.aspx

A: 

Don't worry about hiding your JavaScript code from spiders. It should be the least of your concerns, especially since they don't bother to look at it (except looking for more links to crawl).

http://googlewebmastercentral.blogspot.com/2007/11/spiders-view-of-web-20.html

Matt Ball
but I'm sure they do to prevent black hat SEO.
Neo
@Neo: maybe you could explain _why_ you want to hide your JS from spiders.
Matt Ball
I want to know about the performance of eval(usescape([code]))?
Neo
@Neo: `eval` is slow, and generally regarded as evil (take that with a grain of salt). [Don't `eval` what you don't need to.](http://stackoverflow.com/questions/86513/why-is-using-javascript-eval-function-a-bad-idea)
Matt Ball
A: 

If you want to hide something from spiders, use an external script and setup your robots.txt .

"good" spiders will accept that, "bad" spiders will take a look anyway if they want to.

Dr.Molle
A: 

Unicode character escape sequences

example

var \u0062\u0061\u006E\u0061\u006E\u0061 = "\u0062\u0061\u006E\u0061\u006E\u0061";

is parsed as

var banana = "banana";

Base-36 decoding

(only for case-insensitive alphanumeric data)

parseInt("banana", 36);
> 683010982

683010982 .toString(36);
> "banana"

This could work for certain types of data if you split it up and delimit the numbers.


Base-64 encoding

You can find an implementation here...

base64_encode("banana banana banana!")
> "YmFuYW5hIGJhbmFuYSBiYW5hbmEh"

base64_decode("YmFuYW5hIGJhbmFuYSBiYW5hbmEh")
> "banana banana banana!"

Base-85 encoding

Packs things a bit smaller than base-64. Less popular format, might have to dig for an implementation or make your own.

no