Guest User

Untitled

a guest
Jan 23rd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. requestIdleCallback(() => {
  2. fetch("xxx/a.html").then(res => res.text()).then(html => {
  3. const reg = /target*.js/gi;
  4. const scripts = html.match(reg);
  5. if(scripts && scripts.length) {
  6. scripts.forEach(src => {
  7. const link = document.createElement("link");
  8. link.rel = "prefetch";
  9. link.href = src;
  10. document.head.appendChild(link);
  11. });
  12. }
  13. })
  14. }, { timeout: 1000 * 5 })
Add Comment
Please, Sign In to add comment