untitled
untitled

Reputation: 1127

Preload JSON file with <link rel="preload">

I'm using Angular 5 application and i'm loading quite big JSON file. The problem is that it takes a long time to load main .js bundle, initialize it, bootstrap Angular app which later fetches that JSON file. If i could preload that JSON file while Angular app gets ready, it would speed up initial page load.

I tried to use <link rel="preload" href="/path/to/json" as="script"> but that doesn't help and now JSON file is loaded twice. I tried other as values but nothing works.

What should be correct way to preload JSON file?

Upvotes: 5

Views: 5147

Answers (1)

Takahiro Tsuruda
Takahiro Tsuruda

Reputation: 111

You can use <link rel="preload" href="/path/to/json" as="fetch"> .

https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content#What_types_of_content_can_be_preloaded

Upvotes: 11

Related Questions