SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top