Reputation: 11567
I want to pre-escape part of my javascript code and then include it in my page in the form of eval(unescape([code])). would I be sacrificing performance?
Upvotes: 0
Views: 407
Reputation: 76766
example
var \u0062\u0061\u006E\u0061\u006E\u0061 = "\u0062\u0061\u006E\u0061\u006E\u0061";
is parsed as
var banana = "banana";
(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.
You can find an implementation here...
base64_encode("banana banana banana!")
> "YmFuYW5hIGJhbmFuYSBiYW5hbmEh"
base64_decode("YmFuYW5hIGJhbmFuYSBiYW5hbmEh")
> "banana banana banana!"
Packs things a bit smaller than base-64. Less popular format, might have to dig for an implementation or make your own.
Upvotes: 1
Reputation: 117354
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.
Upvotes: 1
Reputation: 359966
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
Upvotes: 2