Vanilla JS on frontend
-
Hi, I’ve been gradually phasing out jQuery from my site builds. It struck me that I only rely on the jQuery library for toggling the menu. I’d suggest handling this functionality with vanilla JS on the frontend.
Now I’m using this quick ‘n dirty solution;
document.addEventListener("DOMContentLoaded", function() { var trigger = document.getElementById('rmp_menu_trigger-54'); var container = document.getElementById('rmp-container-54'); trigger.addEventListener('click', function() { trigger.classList.toggle('is-active'); container.classList.toggle('rmp-menu-open'); }); });
function custom_theme_functions() { wp_deregister_script( 'jquery' ); } add_action( 'init', 'custom_theme_functions' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.