Hi guy’s,
I have the following menu setup: on desktop i have the primary and secondary menu and on mobile i use the offset menu.
I noticed the sticky and secondary script are loaded on mobile and offsite is loaded on desktop. So i created this script to dequeue where applicable:
function conditional_mobile_styles_scripts() {
if ( function_exists( ‘wp_is_mobile’ ) ) {
if ( wp_is_mobile() ) {
wp_dequeue_script( ‘generate-sticky’ );
wp_dequeue_style( ‘generate-sticky’ );
wp_dequeue_style( ‘generate-secondary-nav-mobile’ );
wp_dequeue_style( ‘generate-secondary-nav’ );
} else {
wp_dequeue_style( ‘generate-offside’ );
wp_dequeue_script( ‘generate-offside’ );
}
}
}
add_action( ‘wp_enqueue_scripts’, ‘conditional_mobile_styles_scripts’, 1500 );
1. When i test the site in desktop and mobile all seems to work fine but i just wanted to double check if i am not breaking any functionality this way?
2. I noticed the following scripts: ‘/generatepress/css/mobile.min.css?ver=2.3.2′ Is these only used on mobile devices? Can i dequeue this on destop?
3. And these: /generatepress/js/menu.min.js?ver=2.3.2’ Is this used offsite menu as well?
Thanks!