For users that have Javascript enabled, the JS files can take a bit of time to initially load. While they're loading, there's a risk that a user clicks a link in personal tools before the javascript is ready.
This is best demonsrated by Notifications' badges; when first loading a page, if the user clicks the badge before the JS is loaded, the system didn't have "time" to take over the click handler to open the popup -- so the result is that the badge link is activated and the user is redirected to Special:Notifications. This is super annoying, and it's not the behavior we'd like to see for users clicking the badge. If they don't have JS enabled, the link should still work, though.
This task is meant to discuss potential solutions to this problem. Attached is an initial idea that allows the use of a "deferredAction" method to trigger the action later. It safely creates an onClick handler that collects the click behavior, and allows the component to request the clicks (or in the case of Notifications, the latest click only) and then act on it. If JS is not enabled, the onClick is obviously ignored.
There are still issues with this patch, so take into account it's a preliminary idea; there are several more ideas on the table to consider, as well, and we should discuss and see if we can come up with a good relatively generic way to solve this problem for other components that need to defer action for clicks -- perhaps even outside of "personal tools" in general.
Note: Applications like "Structured Discussions" for example, can also benefit from that -- they load their DOM from the server, but the clicks on the board links are being taken over by Javascript when it is ready. If the user clicks "reply" or "thank" before JS is ready, they are redirected to a static page as if their JS is disabled. To prevent that, we use tricks like blocking actions on the page while it loads - but that's not ideal.