So I'm currently working on a Javascript-Game and want to load the necessary resources synchronously using the Fetch API. So loading images, sound files, scripts, and stylesheets are no problem. But as I'm loading files like CSS-files as a blob to include in the website, the fonts in these files, which are defined via the font-face-tag, aren't loaded. So is there any way around this problem, or do I have to include stylesheets the old way, to solve the problem, by just putting the link-tags in the head-block?
Here is an example of how I load CSS-files using the Fetch API:
fetch(filePath).then((r) => {
return (r.blob());
}).then((content_) => {
let sheetURL = URL.createObjectURL(content_);
const element = document.createElement("link");
element.rel = "stylesheet";
element.type = "text/css";
element.href = sheetURL;
document.body.appendChild(element);
});
What this should essentially do, is to preload the file and then add it as a tag to the body:
<link type="text/css" rel="stylesheet" href="blob:http://127.0.0.1:4242/0089a94a-d580-4bc3-b808-78a11f2d45d4">
As I said, the stylesheet with the content is loaded and used, but the fonts defined via the font-face tag are ignored.