Hi,
I used this code (via codesnippets) that I found elsewhere to completely remove my sidebar on mobile.
add_filter( 'generate_sidebar_layout', function( $layout ) {
// If we are viewing single post on mobile, set the sidebar
if ( is_single() && wp_is_mobile() ) {
return 'no-sidebar';
}
// Or else, set the regular layout
return $layout;
} );
The issue is that occasionally WP Rocket is caching the mobile view and showing it on desktop. I THINK that maybe it’s because it’s deferring that particular piece of JS that’s controlling it. Does that sound right?
If so, which JS should I exclude from deferring? Which one controls the sidebar?