Detect fetch request on document

Karan Goyal
Feb 21, 2023

--

  const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.initiatorType === "fetch") {
console.log('Fetch request detected to', entry.name);
// For loading aos dynamically
// AOS.init();
}
}
});

observer.observe({
entryTypes: ["resource"]
});

--

--

Karan Goyal
Karan Goyal

Written by Karan Goyal

Full Stack Developer, Top Rated on Upwork, Worked on 90+ jobs in past 9 months and all jobs are rated 5 stars, coding is fun, and always looking forward to code

No responses yet