什么是“Javascript 引导加载程序”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3480150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is a "Javascript Bootloader"?
提问by Abdullah Khan
I have seen this mainly in the source of Facebook Bootloader.setResourceMap({"bMxb7":{"name":....What is exactly a bootloader in javascript? What is its use and purpose?
我主要在 Facebook 的源代码中看到Bootloader.setResourceMap({"bMxb7":{"name":....过 javascript 中的引导加载程序究竟是什么?它的用途和目的是什么?
采纳答案by cweider
Generally speaking, the bootloader is a (relatively) small amount of code responsible for establishing the environment that all subsequent code requires to run, as such it is also the the first code to be executed. It's usually restricted to OSes, but makes sense for FB too.
一般来说,引导加载程序是(相对)少量的代码,负责建立所有后续代码需要运行的环境,因此它也是最先执行的代码。它通常仅限于操作系统,但对 FB 也有意义。
In the case of Facebook, the bootloader will do things like loading additional JS files and other resources that the library needs in addition to the single public <script />the developer included in the document.
在 Facebook 的情况下,除了<script />开发人员包含在文档中的单个公共之外,引导加载程序还会执行诸如加载库需要的其他 JS 文件和其他资源之类的事情。
回答by Adam Lassek
Bootloader is an important part of Facebook's front-end code, which allows Javascript libraries to be lazy-loaded as needed instead of on page load. A couple of Facebook developers go into further detail hereif you'd like to know more.
Bootloader 是 Facebook 前端代码的重要组成部分,它允许根据需要延迟加载 Javascript 库,而不是在页面加载时加载。如果您想了解更多信息,一些 Facebook 开发人员会在此处详细介绍。
You can use RequireJS, LABjsor othersto achieve the same thing.
回答by Guffa
Strictly speaking, there is no such thing.
严格来说,没有这样的事情。
A bootstrap loader (which is the full name of the term) is the part of an operating system that loads the disk operating system from disk, thus the computer lifts itself by the bootstraps, by loading from disk before the disk loading routines are loaded.
引导加载程序(该术语的全称)是操作系统的一部分,它从磁盘加载磁盘操作系统,因此计算机通过引导程序提升自身,通过在加载磁盘加载例程之前从磁盘加载。
There are no Javascript operating systems, so there is no bootstrap loader for Javascript. This is just some object that is named that way, presumably because it does something early in the page load process.
没有 Javascript 操作系统,因此没有用于 Javascript 的引导加载程序。这只是一些以这种方式命名的对象,大概是因为它在页面加载过程的早期做了一些事情。
回答by Sam Sedighian
Here is a video from React.js Conf 2016 that touches on what Bootloader is. But to summarize: Bootloader helps improve the performance of the app but not downloading content unless they are actually needed. The video has the example of the 'share button'
这是来自 React.js Conf 2016 的视频,其中涉及 Bootloader 是什么。但总而言之:引导加载程序有助于提高应用程序的性能,但不会下载内容,除非确实需要它们。视频中有“分享按钮”的例子

