Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

anys-web-plugin-monitor-performance

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anys-web-plugin-monitor-performance

1. web navigation performance 2. `anys-perf` custom element to record first render time 3. fps

latest
npmnpm
Version
8.0.0
Version published
Maintainers
1
Created
Source

AnysMonitorPerformancePlugin

  • web navigation performance
  • anys-perf custom element to record first render time
  • fps

Install

npm i anys-web-plugin-monitor-performance
<script src="https://unpkg.com/anys"></script>
<script src="https://unpkg.com/anys-web-plugin-monitor-performance"></script>
<script>
    const { Anys, AnysMonitorPerformancePlugin } = window.anys;
    const anys = new Anys({
        plugins: [AnysMonitorPerformancePlugin],
    });
</script>

Options

  • performance: boolean (true)
  • fps: boolean | number (true)
const anys = new Anys({
    plugins: [AnysMonitorPerformancePlugin],
    fps: 40, // when fps is lower than 40, anys will write a log
});

Log

performance

{
    type: 'performance.navigation',
    time: Date.now(),
    detail: {
        url,
        redirectCount,
        type,
        timeOrigin,

        startTime,
        unloadEventStart,
        unloadEventEnd,
        redirectStart,
        redirectEnd,
        workerStart,
        fetchStart,
        domainLookupStart,
        domainLookupEnd,
        connectStart,
        secureConnectionStart,
        connectEnd,
        requestStart,
        responseStart,
        responseEnd,
        domInteractive,
        domContentLoadedEventStart,
        domContentLoadedEventEnd,
        domComplete,
        loadEventStart,
        loadEventEnd,

        FP,
        FCP,
        TTFB,
        LCP,
        TTI,

        TCP,
        DNS,
        REQUEST,
        RESPONSE,
        REDIRECT,
        TLS,
        COMPRESSED,
        CACHED,
        PROTOCOL,
    },
}
{
    type: 'performance.measure',
    time: Date.now(),
    name,
    detail: {
        timeOrigin,
        startTime,
        duration,
    },
}
{
    type: 'performance.dom',
    time: Date.now(),
    name,
    data: {
        // dataset on DOM element
        ...
    },
    detail: {
        timeOrigin,
        startTime: domInteractive,
        duration: now - domInteractive,
    },
}

fps

{
    type: 'performance.fps',
    time: Date.now(),
    fps,
    detail: {
        timeOrigin,
        startTime: firstFrame,
        duration: now - firstFrame,
    },
}

API

anys-perf

Custom element for div tag, to monitor a div element's first render time.

<div is="anys-perf" data-name="my-monitor-node"></div>

Dataset:

  • name: the monitor point name (required)

Other dataset properties will be report at the same time.

mark(name)

Plugin method to create a mark and get the measure method.

const anys = new Anys({
    plugins: {
        performance: AnysMonitorPerformancePlugin,
    }
})
const measure = anys.plugins.performance.mark('my-monitor-point');
// ... do some thing
// support async tasks
measure(); // -> write a performance log and clear mark

FAQs

Package last updated on 23 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts