performance - Moving inline Javascript to External Combined Javascript -


hi there busy moving inline javascripts combined.js file. in header have code below. working in wordpress.

the code below makes slider function on page. have moved bulk part of javascript 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 js file, not use document.write write html part page, instead have kept html part in page, , hoping can javascript function execute once custom.js loaded , render html intended.

i have copied part 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 part

(function($){jssor_slider1_starter('slider1_container')})(jquery); 

but not having luck

any ideas why script executes correctly inline, not when include js file appreciated, , advice on how implement call external combined.js file make work appreciated

you need have slider1_container div rendered first before can use it, try putting js call on footer or wrap this:

(function($){jssor_slider1_starter('slider1_container')})(jquery); 

like this:

jquery(document).ready(function() {   (function($){jssor_slider1_starter('slider1_container')})(jquery); }); 

so waits document ready before execute js.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -