Please sign in to comment.
Prevent interruption of ready callbacks
Note: This commit breaks assumption that ready callbacks called syncronously and immediatelly when DOM already parsed at the moment of adding the callback. I hope this assumption isn't very common, considering that jQuery now doesn't provide such guarantee (see ). HTML [spec] stated that one script can interrupt another one: > Otherwise > Immediately execute the script block, even if other scripts are already executing. I'm not sure which set of attributes should have scripts tags to make interruption possible. I guess if one script has `src` and `async` attributes and another one has no `src` attribute (inline script), than it is. As I understand Zepto functions (as well as most of JS code at all) assume that interpreter is single-thread and doesn't interrupt scripts execution. That means that calling any Zepto functions is not safe in general. Since most of Zepto-related code likely placed inside `ready` callbacks, it's worth to protect the callbacks from interruption. I guess it can be achived by piping callback execution over task/events loop, i. e. wrapping callback call into `setTimeout` when it's not piped already via event queue. That's how jQuery [behaves]. By the way, they have one more [argument] to call callbacks asynchronously. : https://html.spec.whatwg.org/multipage/scripting.html#script-processing-model : https://github.com/jquery/jquery/blob/7bb62bb3ae771fc57cc62ee14bd10d94680efb4f/src/core/ready-no-deferred.js#L94 : jquery/jquery#1823 Build size ---------- Calculated for a build with the default modules set: ``` zepto.js 58726 -> 58755 (+28 bytes) zepto.min.js 26427 -> 26453 (+26 bytes) zepto.min.gz 9804 -> 9803 ( -1 bytes) ```
- Loading branch information...