$slider = isset($_GET['slider_type']) ? $_GET['slider_type'] : 'default';
if($slider == 'default')
{
wp_enqueue_script('roundabout-slider', get_bloginfo('template_url').'/sliders/default/jquery.roundabout.js');
wp_enqueue_script('roundabout-shapes', get_bloginfo('template_url').'/sliders/default/jquery.roundabout-shapes.js');
}
elseif($slider == 'nivo')
{
wp_enqueue_script('nivo-slider', get_bloginfo('template_url').'/sliders/nivo/nivo-slider.js');
}
However this is not true in case of enquing the styles. They just don’t get included. Any ideas on how to solve this issue would be greatly appreciated.
- Author had a File in an Envato Bundle
- Author was Featured
- Bought between 1 and 9 items
- Europe
- Exclusive Author
- Has been a member for 2-3 years
- Item was Featured
- Referred between 100 and 199 users
function get_slider_scripts($type)
{
switch($type)
{
case 'content-slider':
wp_enqueue_style('duotive-content-slider-style');
wp_register_script('duotive-slider-calls', get_bloginfo('template_directory')."/js/get-slideshow-js.php?type=content-slider", false, null);
wp_enqueue_script('duotive-slider-calls');
break;
}
}
and called if before the wp_head() so the files get enqueued before the call for wp_head.Thank you so much, Duotive!!! You’re a lifesaver. I’ll give it a try.
I do it a bit differently.
I’ll just throw the css for the sliders into my primary css and I assign different classes to each slider, .nivo, .cycle etc… cuts down unnecessary files and code.
christopherjon said
I do it a bit differently. I’ll just throw the css for the sliders into my primary css and I assign different classes to each slider, .nivo, .cycle etc… cuts down unnecessary files and code.
+1
christopherjon said
I do it a bit differently. I’ll just throw the css for the sliders into my primary css and I assign different classes to each slider, .nivo, .cycle etc… cuts down unnecessary files and code.
That’s what I do now for sliders but imagine the scenario where you have some other specific css files applicable to only specific page (e.g., prettyPhoto for portfolio page). If I include everything in the main css file it will eventually become >1 MB which is unacceptable from the point of view of performance.
weblusive said
christopherjon saidThat’s what I do now for sliders but imagine the scenario where you have some other specific css files applicable to only specific page (e.g., prettyPhoto for portfolio page). If I include everything in the main css file it will eventually become >1 MB which is unacceptable from the point of view of performance.
I do it a bit differently. I’ll just throw the css for the sliders into my primary css and I assign different classes to each slider, .nivo, .cycle etc… cuts down unnecessary files and code.
Css > 1 mb
never seen
That’s what I do now for sliders but imagine the scenario where you have some other specific css files applicable to only specific page (e.g., prettyPhoto for portfolio page). If I include everything in the main css file it will eventually become >1 MB which is unacceptable from the point of view of performance.
Loading multiple files can slow down performance as well. Loading a single 30k css file is going to be faster than loading 2 10k css files.
For myself, I like to compact everything down to as few files as possible. My typical load consists of a css file, a php css file for dynamic stuff, jquery and my custon jquery file.
I’m not going to say one way is better than the other, it really depends on how you code and how your theme works.
