@substrate-system/fouc
    Preparing search index...

    @substrate-system/fouc

    fouc

    tests types module GZip size install size dependencies semantic versioning Common Changelog license

    Flash of Unstyled Content

    Contents

    npm i -S @substrate-system/fouc
    

    Takes a callback, or returns a promise.

    import { fouc } from '@substrate-system/fouc'

    fouc(() => {
    document.body.style.opacity = '1'
    })

    // or returns a promise
    await fouc()

    Add this to your HTML so that it supports devices without Javascript:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <!-- ... -->
    <noscript>
    <style>
    body {
    opacity: 1; /* We set this in JS b/c FOUC */
    }
    </style>
    </noscript>
    <!-- ... -->
    </head>

    This exposes ESM and common JS via package.json exports field.

    import { fouc } from '@substrate-system/fouc'
    
    require('@substrate-system/fouc')
    

    This package exposes minified JS files too. Copy them to a location that is accessible to your web server, then link to them in HTML.

    cp ./node_modules/@substrate-system/fouc/dist/index.min.js ./public/fouc.min.js
    
    <script type="module" src="./fouc.min.js"></script>
    

    Return a promise if a callback is not passed in.

    function fouc (cb?:()=>any):Promise<void>|void