4 ms·
Because it would not be backward compatible, eg: el.style.color = "red" // write console.log(el.style.color) // read el.style.color = "green" // wr
by dorianm 11y ago
Because it would not be backward compatible, eg:
el.style.color = "red" // write
console.log(el.style.color) // read
el.style.color = "green" // write
console.log(el.style.color) // read
Outputs: "red" then "green".
Batched: it outputs "green" then "green".
- coderdude 11y agoThere could be a flag included in the HTTP response header (X-Batch-DOM) or a meta tag like <meta http-equiv="X-Batch-DOM" content="1">. The response header would be a better place for that flag since you can stick a meta tag at any point in your markup (even where it's incorrect to do so). The browser could choose to ignore the meta tag if any JS has executed or it could reload the page with the setting turned on. Not ideal. Anyway, if you feel completely sure that your code would not do anything like you've demonstrated then batching might work fine. Though this basically excludes the safe use of externally linked scripts that you can't control (analytics is one example).