Warning: DOMDocument::loadHTML(): Tag template invalid in Entity, line: 12 in /home/customer/www/robincornett.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466
Warning: DOMDocument::loadHTML(): Tag svg invalid in Entity, line: 14 in /home/customer/www/robincornett.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466
Warning: DOMDocument::loadHTML(): Tag path invalid in Entity, line: 15 in /home/customer/www/robincornett.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466
Warning: DOMDocument::loadHTML(): Tag template invalid in Entity, line: 29 in /home/customer/www/robincornett.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466
Warning: DOMDocument::loadHTML(): Tag svg invalid in Entity, line: 31 in /home/customer/www/robincornett.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466
Warning: DOMDocument::loadHTML(): Tag path invalid in Entity, line: 32 in /home/customer/www/robincornett.com/public_html/wp-content/plugins/gistpress/includes/class-gistpress.php on line 466
A lot of themes include some kind of responsive navigation script. While it feels wasteful to delete that entirely, it feels even more so to load scripts you’re not using, so here’s how I load my theme navigation files only if SuperSide Me is not active:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// you can add this to your theme's functions.php file, but do not include the | |
// opening tag! | |
add_action( 'wp_enqueue_scripts', 'prefix_load_scripts' ); | |
function prefix_load_scripts() { | |
if ( function_exists( 'supersideme_has_content' ) && supersideme_has_content() ) { | |
return; | |
} | |
wp_enqueue_script( 'leaven-responsive-menu', get_stylesheet_directory_uri() . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0', true ); | |
$output = array( | |
'mainMenu' => 'Menu', | |
'subMenu' => 'Menu', | |
); | |
wp_localize_script( 'leaven-responsive-menu', 'LeavenL10n', $output ); | |
} |
We check to see if SuperSide Me is active, and also to see if the menu panel can be generated. If it can, then there is no need to load the theme’s responsive navigation script.
Return to SuperSide Me