开发者

is unescaping a javascript pre-escaped function a bad idea for performance?

开发者 https://www.devze.com 2023-01-18 07:48 出处:网络
I want to pre-escape part of my javascript code and then include it in my page in the form of开发者_如何学Ceval(unescape([code])). would I be sacrificing performance? Don\'t worry about hiding your Ja

I want to pre-escape part of my javascript code and then include it in my page in the form of开发者_如何学C eval(unescape([code])). would I be sacrificing performance?


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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号