onResize and onLoad handlers to toggle mobile layout
Your code is mainly about this test:


if (window.innerWidth &gt;= MIN_WIDTH_BREAKPOINT)



You shouldn't be doing this using JavaScript to do this at all. Width-dependent layout is exactly what CSS media queries are for.

Furthermore, I would caution you against activating the mobile layout based on the width. This will break the "Request Desktop Site" feature in iOS Mobile Safari, which uses User-Agent switching instead.