npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

index-html

v1.0.5

Published

14kb asset preloader library

Downloads

12

Readme

index-html

compile an optimal index.html preloader for a directory of assets

this is based on some assumptions

  • Best practice: inline critical path assets for fastest initial load experience capped at 14kb
  • Load all other assets dynamically after that
  • Index payload: app shell loading spash animation inlined with dead simple logic to load JS and CSS
  • Secondary payloads: index.js app logic and index.css app styles
  • Delta payloads detertmined in main app logic (loaded in prev step)

install

npm i index-html --save-dev

usage

index-html package is intended for use with compiled assets, ready for deployment, as a last pass in your asset pipeline to create a decently simple preloader that makes some fair tradeoffs.

Reccomended usage as an npm script ala:

"compile": "index-html dist > dist/index.html"

index-html is a sort of compiler that accepts a src directory for its first argument. Some files are magic:

  • index.js (optional) loaded by index.html first
  • index.css (optional) loaded by index.html after the js completes
  • index.svg (optional) svg file to use for the splash screen animation (inlined in index.html)
  • preload.js (optional) module for preloader scripting (compiled inline to index.html)
  • preload.css (optional) module for preloader scripting (compiled inline to index.html)

All of this compiles into a minified index.html spashscreen. (if the svg and preload are greater than 14kb the compiler will fail.)

lifecycle

  • Displays one centered animated svg asset. Override with index.svg (defaults dots)
  • Inlines css to do a very basic browser reset. Override with preload.css
  • Lazy loads index.css and index.js
  • Runs a mini rAF event loop for displaying progress and load completion cleanup logic. Override w/ preload.js
  • Page emits complete, which again can be overriddenwith preload.js

api

// preload.js
module.exports = {

  before: function() {
    // just before rAF inits
  },

  draw: function() {
    // called every frame
  },

  complete: function() {
    // called when index.js and index.css have been loaded
  }
}

todo

  • font preloading
  • spritesheets
  • companion lib for resource eaching (maybe just cache manifest)
  • research service worker, favicon, manifest