Fast, convenient, adaptive menu for 1075 categories (36000 products)

image



Briefly about the menu





Menu Requirements





The full version of the menu can be viewed codepen.io/andrej-sh/pen/eYOrNEZ



Beginning of HTML code



Code piece



JavaScript Code Explanation



I planned to do without JavaScript, but the implementation of closing the open menu when I clicked on CSS again did not seem to be implemented for radio + checkbox. And the code is simple and straightforward, and even if it is accidentally deleted, it cannot make the site not working (when testing the menu with jQuery, the site did not work for 5 minutes due to the fact that it first connected the script remotely and the link had http instead of https).



<script> function clickRadio(el) { var siblings = document.querySelectorAll("input[type='radio'][name='" + el.name + "']"); for (var i = 0; i < siblings.length; i++) { if (siblings[i] != el) siblings[i].oldChecked = false; } if (el.oldChecked) el.checked = false; el.oldChecked = el.checked; }</script>
      
      





Similar menu using jQuery



The first version of the menu was in jQuery, implemented through the input "checkbox". Even through the script, the appearance of the "+ -" characters was configured when opening and hiding the menu. In terms of functionality and appearance, it is absolutely the same as about the menu described earlier. But! download speed was noticeably worse. For example, “Maximum Potential FID Delay” becomes 1 second longer. “Download time for interaction" is 0.6-0.8 seconds longer. "Download time of the first content" by 0.3-0.4 seconds. Scripts load 0.5 seconds longer.



Images from download speed verification services



For computers



For mobile



Lighthouse







All Articles