I have already made the mobile menu function for all screen sizes by simply changing this in the plugins.js file
I changed 959>=$(window) to 0<=$(window) and added a menu button to the navbar to open the menu.
I also had to make some changes to the css but that was easy. Just commented out all the .horizontal-mega-menu classes and removed the @media screen and (max-width: 959px) for the .mobile-navigation classes.
Link to see how it looks and functions: https://www.loveisarose.com/
This works great but I had a thought about page speed which lead to a question.
Is it possible to remove the clone functionality and have the menu live within in <div id="js-mobile-navigation" class="mobile-navigation"></div>?
Instead of using javascript to move it there on every page load?
I know I would have to move the readytheme navigation set to be within that mobile navigation div but i'm not sure what part of the script in the plugins.js file would need to be removed.
Trying to stay under that 3 second load time and I was thinking since we want to use that menu functionality for all screen sizes, it'd be better to have it live where it ends up after the script runs.
Less scripts having to process should help that load time I'd think or hope at least.
Any insight, suggestions, or points in the right direction would be appreciated.
Thanks.
Code:
function mobileNavigation(){function f(){0<=$(window).innerWidth()?0==$("#js-mobile-navigation ul").length&&(g.show(),$(b).append(h),$("#js-mobile-navigation ul li span").each(function(){if("0"!=$(this).next().length){$(this).addClass("parent");var a=$(this).children("a").text();$(this).parent("li").append('<span data-name="'+a+'" data-rt-icon="" class="next"></span>')}})):0==$("#js-navigation-bar ul").length&&(g.hide(),$("#js-mobile-navigation").find($(".clone").remove()),$("#js-navigation-bar").prepend(h.removeClass("hide")), $(".next").remove())}var b=$("#js-mobile-navigation"),g=$("#js-mobile-menu-button"),h=$("#js-navigation-set");$(window).on("load resize",function(){f()});b.on("click","span.next",function(a){a.stopPropagation();a.preventDefault();a.stopImmediatePropagation();$(this).siblings("span").closest("ul").addClass("hide");$parent=$(this).text();$new=$(this).prev("ul").clone().addClass("clone").appendTo(b);a=$(this).attr("data-name");$('<li><span class="back"><a> Back</a></span></li>').prependTo($new); if($(".navigation-trail").length)c=$(this).parent("li").siblings(".navigation-trail").clone(),$(c).children("span").append(" / "+a),c.prependTo($new);else{var c=$('<li class="navigation-trail"><span>Home</span></li>').prependTo($new);$(c).children("span").append(" / "+a)}});b.on("click","span.back",function(a){a.stopPropagation();a.preventDefault();a.stopImmediatePropagation();$(this).closest("ul").prev("ul").removeClass("hide");breadcrumb=$("a.root").text();last=breadcrumb.substr(breadcrumb.lastIndexOf(" / ")+ 1);$old=$(this).closest("ul");$old.remove();$("a.root").html(function(a,b){return b.replace(last,"")})})}mobileNavigation=new mobileNavigation;
I also had to make some changes to the css but that was easy. Just commented out all the .horizontal-mega-menu classes and removed the @media screen and (max-width: 959px) for the .mobile-navigation classes.
Link to see how it looks and functions: https://www.loveisarose.com/
This works great but I had a thought about page speed which lead to a question.
Is it possible to remove the clone functionality and have the menu live within in <div id="js-mobile-navigation" class="mobile-navigation"></div>?
Instead of using javascript to move it there on every page load?
I know I would have to move the readytheme navigation set to be within that mobile navigation div but i'm not sure what part of the script in the plugins.js file would need to be removed.
Trying to stay under that 3 second load time and I was thinking since we want to use that menu functionality for all screen sizes, it'd be better to have it live where it ends up after the script runs.
Less scripts having to process should help that load time I'd think or hope at least.
Any insight, suggestions, or points in the right direction would be appreciated.
Thanks.
Comment