开发者

Can modernizr and/or yepnope react to bots and spiders?

I have some JS running on a page which pops up a modal localisation select box. I would like to prevent this from happening for bots /crawlers. Is the开发者_如何学Gore a way to do this using Modernizr and / or yepnope.js?


Most bots won't run any Javascript code at all. They'll download your code and examine it to see what it does or what it's about, or whatever that particular bot's function is, but they generally don't need to actually run any JS code to do this.

Those that do run JS code will do so in an environment that will differ from bot to bot. Some may simulate a browser environment, others may run in an actual brower. But without knowing about the innards of all the bots you're likely to encounter, you really won't be able to solve it for sure with a tool like Modernizr.

When it comes to looking at your end users's browser, doing browser detection is considered a bad thing, and feature detection (ie Modernizr) is considered a better solution.

However the rules change when it comes to bots, because of the factors I've discussed above, and it does indeed become legitimate to do detection for them based on their user-agent string.

Any legitimate bot will provide a UA string that identifies itself as such, and should be fairly easy to spot.

If a bot isn't providing an identifiable UA string, then it isn't a legitimate bot, so there's no reason for you to give it any special treatment to make life easier for it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜