3 ms·
I can't believe all the seconds on that page aren't synchronized. Or at least on my tablet they aren't! They're flipping at slightly different moments. Should h
by russellbeattie 7y ago
I can't believe all the seconds on that page aren't synchronized. Or at least on my tablet they aren't! They're flipping at slightly different moments. Should have had one timer event firing to change every element at the same tick.
- reilly3000 7y agoI thought that was happening at first on my fast desktop, but it seemed to be to be an optical illusion the more I looked at it. I’d probably have to set some breakpoints or something to verify, but it’s Friday night...
- missblit 7y agoThey are all updated in the same JavaScript function. However each clock is updated in a seperate call to .innerHTML. This means the DOM is updated seperately for each clock instead of just once for all the clocks. So depending on how eager your browser is about doing layouts, I could imagine different clocks updating on different frames to be a possibility.
- stjo 7y agoI’m fairly sure the JS standard guarantees that no layouting (or any form of rendering) would happen mid function execution. Haven’t looked in the source code yet, but if they do function updateAllClocks() { A.innerHTML = ...; B.innerHTML = ...; } Then A and B would update on the screen on the same frame and the order doesn’t matter (If A is not parent of B or vice versa of course) This is not true if they do a lot of setTimeouts(), but is true for all other “normal” synchronous code.
- chrisseaton 7y ago> I’m fairly sure the JS standard guarantees that no layouting (or any form of rendering) would happen mid function execution. I think the JS standard doesn't have any notion or layout of rendering. Which part of the standard are you referring to?
- afterburner 7y agoYou sure you're not looking at the "Your Device's Clock" part of the page? All mine (except that nice little box) are in sync.