Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- requestIdleCallback(() => {
- fetch("xxx/a.html").then(res => res.text()).then(html => {
- const reg = /target*.js/gi;
- const scripts = html.match(reg);
- if(scripts && scripts.length) {
- scripts.forEach(src => {
- const link = document.createElement("link");
- link.rel = "prefetch";
- link.href = src;
- document.head.appendChild(link);
- });
- }
- })
- }, { timeout: 1000 * 5 })
Add Comment
Please, Sign In to add comment