<!doctype html>
<html>
<body>
<script>
function invalidateStyle() {
const img = document.querySelector('img');
img.setAttribute('src', './big-image.png');
const newStyle = document.createElement('style');
newStyle.textContent = `
div {
margin: 1px;
}
`;
document.head.appendChild(newStyle);
}
function forceLayout() {
const img = document.querySelector('img');
const unused = img.offsetHeight;
}
function performActions() {
invalidateStyle();
forceLayout();
}
setTimeout(performActions, 1000)
</script>
<div>
<img>
</div>
<div>
text
</div>
</body>
</html>