0.0.1 • Published 2 months ago

@substrate-system/fouc v0.0.1

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
2 months ago

fouc

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

Flash of Unstyled Content

Install

npm i -S @substrate-system/fouc

Example

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()

noscript

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>

API

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

ESM

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

Common JS

require('@substrate-system/fouc')

pre-built JS

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.

copy

cp ./node_modules/@substrate-system/fouc/dist/index.min.js ./public/fouc.min.js

HTML

<script type="module" src="./fouc.min.js"></script>

fouc

Return a promise if a callback is not passed in.

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

2 months ago

0.0.0

2 months ago