Skip to content

Instantly share code, notes, and snippets.

@vigneshshanmugam
Last active February 17, 2020 21:10
Show Gist options
  • Save vigneshshanmugam/2bdcba10d0338eca1ef2ee3dd0869d4f to your computer and use it in GitHub Desktop.
Save vigneshshanmugam/2bdcba10d0338eca1ef2ee3dd0869d4f to your computer and use it in GitHub Desktop.
Observing longtasks using performance observer
const observer = new PerformanceObserver(function(list) {
const entries = list.getEntries();
// An example entry looks something like this
const exampleEntry = {
name: "same-origin-descendant",
entryType: "longtask",
startTime: 1023.40999995591,
duration: 187.19000002602115,
attribution: [
{
name: "unknown",
entryType: "taskattribution",
startTime: 0,
duration: 0,
containerType: "iframe",
containerSrc: "child.html",
containerId: "",
containerName: "child1"
}
]
};
});
observer.observe({ type: "longtask", buffered: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment