Why are preload link not working for JSON requests ?

后端 未结 9 694
星月不相逢
星月不相逢 2020-12-30 02:24

The JavaScript on my website loads several JSON to initialize itself.

I would like to preload them so, when the JavaScript will launch an Ajax request on it, they wi

9条回答
  •  -上瘾入骨i
    2020-12-30 03:01

    Here is the approach that works both in Chrome and Safari.

    
    
    fetch('/data.json', {
        method: 'GET',
        credentials: 'include',
        mode: 'no-cors',
    })
    

    This answer contains more details and explanation why and how does it work https://stackoverflow.com/a/63814972/1387163

提交回复
热议问题