forked from izu/student-web-if-development-kit
17 lines
498 B
JavaScript
17 lines
498 B
JavaScript
import { ViewerApi } from './viewer-api.js';
|
|
|
|
export class ViewerPrefetch {
|
|
static fromLocation(location = window.location) {
|
|
const params = new URLSearchParams(location.search);
|
|
const id = params.get('id');
|
|
if (!id) return;
|
|
|
|
const link = document.createElement('link');
|
|
link.rel = 'prefetch';
|
|
link.as = 'fetch';
|
|
link.crossOrigin = 'anonymous';
|
|
link.href = ViewerApi.assetUrl(id);
|
|
document.head.appendChild(link);
|
|
}
|
|
}
|