Skip to content

Commit

Permalink
Merge pull request #9 from indykoning/patch-1
Browse files Browse the repository at this point in the history
Reduce Forced reflows
  • Loading branch information
BobWez98 authored Oct 22, 2024
2 parents aaef323 + 6a0d272 commit ad8974a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions resources/views/partials/head.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<script>
window.responsiveResizeObserver = new ResizeObserver((entries) => {
entries.forEach(entry => {
const imgWidth = entry.target.getBoundingClientRect().width;
const imgHeight = entry.target.getBoundingClientRect().height;
const bounds = entry.target.getBoundingClientRect();
const imgWidth = bounds.width;
const imgHeight = bounds.height;
const pixelRatio = window.devicePixelRatio * imgWidth;
entry.target.parentNode.querySelectorAll('source').forEach((source) => {
requestAnimationFrame(() => entry.target.parentNode.querySelectorAll('source').forEach((source) => {
source.sizes = pixelRatio + 'px';
});
}));
});
});
</script>

0 comments on commit ad8974a

Please sign in to comment.