dvAfterBootPreloadsBody function
JavaScript statements that append a <link rel="preload" as="fetch" crossorigin="anonymous"> for each of hrefs once the app and its
renderer have downloaded (dvAfterBootDownloadsDetector). guard, when
given, is an expression that must be true for anything to happen.
Implementation
String dvAfterBootPreloadsBody(List<String> hrefs, {String? guard}) {
// JSON in a script: `<` escaped so a name cannot close the element.
final String names = jsonEncode(hrefs).replaceAll('<', '\\u003c');
return '$dvAfterBootDownloadsDetector'
'${guard == null ? '' : 'if(!($guard))return;'}'
'dvAfterBoot(function(){var d=document;$names.forEach(function(h){'
'var l=d.createElement("link");l.rel="preload";l.as="fetch";'
'l.crossOrigin="anonymous";l.href=h;d.head.appendChild(l)})});';
}