An editor loaded on demand
Open the editor: the response names editor.css and editor.js, and the browser loads them before it calls Editor. Open it again, or after a page transition: they are loaded already, nothing is requested.
Names of the static files, e.g. from the manifest of the bundler.
The files a module needs; with a priority, they are preloaded while the network is idle.
The loaded script makes the module available when it runs.
Pagelets use the names of the map too.
Bootloader::setResourceMap([
'editor.css' => ['type' => 'css', 'src' => '/bootloaded/editor.css'],
'editor.js' => ['type' => 'js', 'src' => '/bootloaded/editor.js'],
]);
Bootloader::enableBootload(['Editor' => ['editor.css', 'editor.js']]);
return (new AsyncResponse())
->call('Editor', 'open', [TransportMarker::element('draft')])
->send();
// /bootloaded/editor.js, not in the bundle
registerModules({ Editor: class { open(textarea) { … } } });
Open the editor: the response names editor.css and editor.js, and the browser loads them before it calls Editor. Open it again, or after a page transition: they are loaded already, nothing is requested.