Menu
Menu Sheet Overlay
Search
Search Sheet

PWA Quiet State

    What is the PWA “quiet” state?

    The PWA becomes “quiet” when it’s loaded, fetched the assets needed to render and is responsive to the user. Often it’s better to delay some work (such as prefetching assets that might be used in the future) until the PWA has finished loading, and the Performance Manager provides support for this via the PWAQuietEvent and the pwaIsQuiet property.

    The Performance Manager monitors internal conditions to detect the PWA becoming quiet. The exact conditions monitored can vary, depending on whether task-splitting and download management are enabled. The monitoring may also change in future versions of the SDK. However, PWA code can rely on the following:

    The PWAQuietEvent and callWhenQuiet

    The PWAQuietEvent is sent when the PWA has been busy and becomes quiet. It may be sent multiple times during the life of a PWA, but often PWA code will only want to detect the first event. To simplify your code, use the callWhenQuiet method of the PerformanceManager, as in this example, where we call prefetchAssets when the PWA becomes quiet:

    import {PerformanceManager} from './performance-manager'
    
    const performanceManager = PerformanceManager.getManager()
    
    // If the PWA is quiet, prefetchAssets is called immediately. If the PWA is
    // busy, prefetchAssets is called when the PWA becomes quiet.
    performanceManager.callWhenQuiet(prefetchAssets)