3 ms·
I think there's some fairly clever stuff going on. The page source is pretty simple (yes, I'm sure we've ALL looked at it at one point). Take this function for
by jkush 19y ago
I think there's some fairly clever stuff going on. The page source is pretty simple (yes, I'm sure we've ALL looked at it at one point). Take this function for instance:
function byId(id) {
return document.getElementById(id);
}
My guess is that the function body is rendered differently for different browsers. If that's true, it's a clever way of doing cross browser Javascript.
- nostrademons 19y agodocument.getElementById is generally pretty portable across browsers. And another clever way of doing cross-browser JavaScript is just to use a mature JS library like Prototype or JQuery. They all give you byId for free, in the form of the $ function.
- jkush 19y agoI'm with you there - prototype is first class stuff. I wasn't sure if getElementById was supported by Opera or Safari. If it is, it looks like byId() is good way to save some typing.