In most browsers specially desktop browsers, you're able to zoom in and out using CTRL/CMD++ or CTRL/CMD+-.
Most of the time, there's no problem as your website should take into account responsiveness but what if you want to update your website based on your user's browser zoom percent?
Math.round((window.outerWidth / window.innerWidth) * 100)
Zooming is part of accessibility and having your website usable even when the user being zoomed in is important.
When you have your inspector open and it's docked to the left or right, the calculation becomes inaccurate as the
innerWidth doesn't take into account the inspector.
Best viewed in debug mode:
How would you improve the code or do you have other ways on how you determine browser zoom?
Top comments (0)