Suppose we have two menus: one for wide screens, the other for narrow ones. One CSS-code with media queries can not do - the menu has different HTML.
What would be better in terms of increasing the speed of the site of the two options below?
- Using JavaScript, hide one menu and show another when reaching the key width of the browser window. In this case, in the same HTML file, we will have two different in the HTML structure, but the menu links that are the same for the set of links. One of them will have
display: none. - When you reach the key screen width, use JavaScript to delete (just "delete", not hide, as in the previous case) one menu and add another via
AJAX. The HTML code will be cleaner, but with slow internet, which still has a place to be on mobile devices, the menu may load from the server longer than we would like.