Hi There I am busy moving all my inline javascripts to a combined.js file. In my header I have the code below. I am working in wordpress.
The code below makes a slider function on my page. I have already moved the bulk part of the javascript to a combined js file.
<br /><br /><script>(function($){jssor_slider1_starter = function (containerId) {var jssor_slider1 = new $JssorSlider$(containerId, {$DragOrientation: 3, $ArrowNavigatorOptions: {$Class: $JssorArrowNavigator$, $ChanceToShow: 2 }}); function ScaleSlider() { var windowWidth = $JssorUtils$.$GetWindowSize(window).x; if (windowWidth) jssor_slider1.$ScaleWidth(windowWidth); else window.setTimeout(ScaleSlider, 30);}
$Jssor$.$AddEvent(window, "load", ScaleSlider);
$Jssor$.$AddEvent(window, "resize", $Jssor$.$WindowResizeFilter(window, ScaleSlider));
$Jssor$.$AddEvent(window, "orientationchange", ScaleSlider);
};})(jQuery); Slider Javascript (function($){jssor_slider1_starter('slider1_container')})(jQuery);
I have tried moving these parts to the Js file, but do not use document.Write to write the html part to the page, instead I have kept the html part in the page, and was hoping that I can get the JavaScript function to execute once the custom.js is loaded and this will render the html as intended.
I have copied this part to the combine.js file.
(function($){jssor_slider1_starter = function (containerId) {var jssor_slider1 = new $JssorSlider$(containerId, {$DragOrientation: 3, $ArrowNavigatorOptions: {$Class: $JssorArrowNavigator$, $ChanceToShow: 2 }}); function ScaleSlider() { var windowWidth = $JssorUtils$.$GetWindowSize(window).x; if (windowWidth) jssor_slider1.$ScaleWidth(windowWidth); else window.setTimeout(ScaleSlider, 30);}
$Jssor$.$AddEvent(window, "load", ScaleSlider);
$Jssor$.$AddEvent(window, "resize", $Jssor$.$WindowResizeFilter(window, ScaleSlider));
$Jssor$.$AddEvent(window, "orientationchange", ScaleSlider);
};})(jQuery);
and also this part
(function($){jssor_slider1_starter('slider1_container')})(jQuery);
but I am not having luck
any ideas why this script executes correctly inline, but not when I include it into the js file will be appreciated, and also any advice on how to implement the call from the external combined.js file to make this work will be much appreciated