Friday, 15 May 2015

javascript - How do I push script file into LABjs loading queue? -



javascript - How do I push script file into LABjs loading queue? -

i using labjs defer loading of scripts , in sub pages pushing queue inline script so.

<script> var _loadingqueue = [];</script> <script> _loadingqueue.push(function(){ var scheduledpmtdata = {'paymentcount' : 0}; ...snip... }); </script>

then within main $lab do

if( typeof( window[ '_loadingqueue' ]) !== "undefined"){ for(var i=0,len=_loadingqueue.length; i<len; i++){ $loaddefer = $loaddefer.wait(_loadingqueue[i]); } }

my inline script has come point want set in external js file. how maintain same type of loading script file not inline?

this did working. if can refactored, please allow me know.

added var <script> var _loadingqueuescript = [];</script>

then inline code was, did

<script> _loadingqueuescript = "/assets/scripts/source/addevent.js"; </script>

then under previous $loaddefer.wait() added

if( typeof( window[ '_loadingqueuescript' ]) !== "undefined"){ $loaddefer = $loaddefer.script(_loadingqueuescript); }

javascript labjs

No comments:

Post a Comment