I have found out that when I have a matchMedia query based on width which is listening in a page, it is called when I print it.
Here is a snippet that would be more comprehensive :
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no,viewport-fit=cover" />
</head>
<body>
<div>Open me in chrome, look at the console and print the page</div>
<script>
const mediaQuery = window.matchMedia('only screen and (min-width: 768px)')
mediaQuery.addEventListener('change', () => {
console.log('change width event', { innerWidth: window.innerWidth, outerWidth: window.outerWidth })
})
</script>
</body>
</html>
In my console I can see that window.innerWidth has the value 555 when I print and then the mediaQuery is called right after this with the correct value of my window (which is bigger than 555).
Why does this happen, how can we disable this ?