views:

66

answers:

3

I have noticed that facebook has random element IDs for every element - including elements that have no unique element id.

<div id="__w2_YvdN1r2_loading">blah</div>

Any ideas why they do this on every element & how they do this?

+1  A: 

One reason I can think of for "why" would be to prevent, or at least reduce the incidence of, screen scraping - if the IDs are indeed random. As to how, there are inumerable ways to generate pseudo-random values and any one of them could be coerced to produce a string that resembles __w2_YvdN1r2.

Given how Javascript heavy Facebook is, I'd be quite surprised if the IDs are as random as you think, unless the values are also output into a javascript array/object/store of some description for the pages javascript to use.

Rob
maybe to more easily handle references by javascript ? im not sure if they are random EVERY time or just RANDOM IDs ? if they are random only one time - maybe to assist javascript identification of elements that dont have unique IDs ?
Tom
@Tom, if they're not "random every time", then they're deterministic. If there's an alogithm used to generate the IDs then by their very nature they can't be "random" (ignoring the fact that random values generated by a computer are usually the product of an algorithm)
Rob
A: 

So that it's harder to scrape meaningfully, probably just a string of random chars.

TL Stillman
A: 

I am assuming this is to reference the base64 encoded UUIDs that they may be associated with -- perhaps representing a user or token.

Greg
hmm i thought it might be to allow for Designers not to bother Developers - that is, using Javascript heavily - if they assign random elements to everything then developers can edit the DOM and designers dont have to continually bother them ?
Tom