Topic: Better JavaScript-Handling (some code included)
The current version of Arras (1.5.0.1) seems to be pretty "dumb" when it comes to the JavaScript files. For example it loads the jQuery-UI and Cycle PlugIn-Files even if they aren't used at all.
I made a quick fix for this behavior but unfortunately I don't have the time to test it as much as it should be tested. If you make the following changes to some of the files, the jQuery UI-files are only loaded if a Tabbed Sidebar is used and the Cycle-PlugIn is only loaded if the Slideshow is activated in the settings.
It would probably be a good idea to modify new versions of Arras so it doesn't load stuff it doesn't need (and IMHO it really DOES matter if 50 KB of unused JS-files are loaded or if not...)
So here we go:
library\slideshow.php
replace
add_action('wp_footer', 'arras_add_slideshow_js');with:
if (arras_get_option('enable_slideshow') && ( is_home() || is_front_page() )) {
add_action('wp_footer', 'arras_add_slideshow_js');
}header.php
replace
wp_enqueue_script('jquery-ui-tabs', null, array('jquery-ui-core', 'jquery'), null, false);with:
if (is_active_widget('arras_tabbed_sidebar')) {
wp_enqueue_script('jquery-ui-tabs', null, array('jquery-ui-core', 'jquery'), null, false);
}and replace
if ( is_home() || is_front_page() ) {
wp_enqueue_script('jquery-cycle', get_template_directory_uri() . '/js/jquery.cycle.min.js', 'jquery', null, true);
}with:
if (arras_get_option('enable_slideshow') && ( is_home() || is_front_page() )) {
wp_enqueue_script('jquery-cycle', get_template_directory_uri() . '/js/jquery.cycle.min.js', 'jquery', null, true);
}finally, replace:
wp_enqueue_script('jquery-ui-tabs', null, array('jquery-ui-core', 'jquery'), null, false);with:
if (is_active_widget(false, false, 'arras_tabbed_sidebar')) {
wp_enqueue_script('jquery-ui-tabs', null, array('jquery-ui-core', 'jquery'), null, false);
} js/header.js.php
Replace
$('.multi-sidebar').tabs();with
<?php if (is_active_widget(false, false, 'arras_tabbed_sidebar')) { ?>
$('.multi-sidebar').tabs();
<?php } ?>