问题
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?
回答1:
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.
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.
回答2:
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 here if you'd like to know more.
You can use RequireJS, LABjs or others to achieve the same thing.
回答3:
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.
回答4:
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'
https://youtu.be/SnAq9tbeRm4?t=17m16s
来源:https://stackoverflow.com/questions/3480150/what-is-a-javascript-bootloader