简体   繁体   English

分析-head.js如何实现并行资源的序列化?

[英]Analysis - How does head.js implement serialization of parallel resources?

From the website -> here 从网站-> 这里

// load files in parallel but execute them in sequence
head.js("file1.js", "file2.js", ... "fileN.js");

How is this implemented? 如何实施? I'm looking in load.js -> here 我正在寻找load.js-> 这里

But can't seem to find the source where this is implemented. 但是似乎找不到实现此目标的源。

Looks like api.load is an alias for api.js and is defined twice. 貌似api.load是一个别名api.js和被定义了两次。

If the navigator is compatible with async then it's the navigator that insures the ordering & execution of the scripts as they are just appended in the requested order (ie10, ff, chrome) 如果导航器与异步兼容,那么导航器可以确保脚本的顺序和执行,因为它们只是按照请求的顺序(即10,ff,chrome)追加

Otherwise there is a hack that is used (text/cache hack) which injects the scripts with a phony mime/type, and once they are all loaded (callback triggers) re-injects them with the correct mime/type (but since the url is already known to the browser the content is not re-fetched) thus triggering the real execution/interpretation by the browser but this time in order (ie6-ie9) 否则,将使用一种hack(文本/缓存hack),该脚本以伪造的mime /类型注入脚本,并且一旦全部加载(回调触发器),便以正确的mime /类型注入脚本(但是由于URL浏览器已经知道它的内容没有被重新获取),从而触发了浏览器的真正执行/解释,但是这次是按顺序进行的(即6-ie9)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM