I was looking at google.com source and saw:
<!doctype html><html onmousemove="google&&google.fade&&google.fade(event)">
I did not know the HTML tag could accept event listeners. What is the difference of placing the event listener on the HTML tag versus the BODY tag? Is there any difference in the event bubbling?
I saw this a couple of days ago and didn’t give it much thought. But one reason could be “performance” as it always is with Google 🙂
For an extremely slow client,
<html>will be parsed first thing and theonmousemovehandler will be ready to fire if the user moves the mouse. If there is too much content inside<head>, this may be more preferable as theonclickon<body>may take a little while to register as all that head content has to be downloaded and parsed first.Actually that is already happening, there is approximately
2KBof content before<body>appears.