Comments (8)
Despite the fact that it may have worked in the past, it's not really a supported use case that you "suspend" the execution of a chain and then resume it later after some other logic. There's lots of potential race conditions such activity could introduce. Your usage is not really an intended or supported functionality, at least for now. Perhaps the re-write I'm working on will be more robust for it, but honestly that won't be a major design goal.
May I ask, why do you need to resume the $LAB chain later? Why not use another chain, or just execute the code right away?
from labjs.
Currently i load mootools core and LABjs via standard script tag, then the additional JS like mootools-more, clientcide and my own modules, so the domready occurs before my own modules are loaded via script tag.
So with the instance - chain i can make sure that my modules are loaded before i try to use it in inline code, otherwise it can happen that js don't know the module / class cause its not loaded yet.
At least i would wish there was a .completed() function which (similar to wait, but fires parallel)
from labjs.
But I'm still not sure I understand why this implies that you need to split up the $LAB chain? I understand using a script tag to blocking load of mootools (because of doc.write) and LABjs, but then just need one chain that loads all the other JS files, right? Also, how does loading in CSS in the middle of all that factor in?
from labjs.
The CSS breaks the chain somehow, don't know why.
I built a lablsloaded Eventhandler for mootools, so when the scriptchain is loaded. i set at the footer async.wait(function() {Browser.labjsloaded = true} and check via the handler. Maybe i set different breakpoints for different modules, don't know if that complexity is worth the few microseconds gain then.
from labjs.
I don't understand why you can't do this:
var asyncjs = $LAB
.script('mootools-more').wait()
.script('clientcode').wait()
.script('my own modules').wait(function() {
alert('Scripts Loaded');
alert('first call');
alert('second call');
alert('third call');
});
then some CSS via link tag.
You mentioned something about inline Javascript. If you're trying to prevent that code from being run until all of the scripts are loaded, why not just use the <script> tag to load all of the scripts? This would prevent the domready event from being fired until your own modules are loaded.
from labjs.
well i have another approch now with mootools.
$Lab
.script(mootools...).wait()
.script(...).wait(function() {
Browser.labjsloaded = true;
}
and a custom eventhandler:
Element.Events.labjsloaded = {
onAdd: function(fn){
if (Browser.labjsloaded) fn.call(this);
}
};
(function(){
var labjsloaded = function(){
console.log('Labs Ready')
window.fireEvent('labjsloaded');
document.fireEvent('labjsloaded');
};
var repeat = function(){
(Browser.labjsloaded == true) ? labjsloaded() : repeat.delay(10);
}
repeat();
})();
so i can use now:
window.addEvent('labjsloaded',function() {
// do this after the scripts are loaded...
});
from labjs.
closing.
from labjs.
FYI: resuming of $LAB chains will be supported in 2.0.
from labjs.
Related Issues (20)
- BOM issues HOT 4
- HTTP2 or SPDY and LABjs HOT 2
- swallowing errors doesn't seem right HOT 1
- It's nearing time for 3.0 HOT 31
- LAB inserts scripts at the beginning of the <head> HOT 7
- how to use LAB when Chrome blocks inline scripts ? HOT 2
- LABjs regular expression breaks for Windows apps
- Why not add localStorage to cache the scripts? HOT 6
- What is the role of first line?
- labjs.com is down HOT 1
- Recovering from 404 HOT 1
- Refactor out arguments.callee HOT 1
- huge longshot, but... might be a bug with LAB.js here. HOT 8
- www.labjs.com is not working
- LABjs blocking the executation of jquery each()
- setAttribute("as", "script") in chrome 51.0.2704.84 window7 messy code
- Seeking for a stable v3.0 package
- Current project status HOT 2
- [Question] Does LABjs scrub out the debugger keyword? HOT 2
- JsDelivr - I can't see '.js' files HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from labjs.