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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@woowabros/vite-plugin-critical-script

v1.0.0

Published

Vite plugin to inline TypeScript modules as critical HTML scripts that run before the main JS bundle — for API prefetch, asset preload, webview bridge, LCP optimization

Readme

critical-script

English | 한국어

critical-script is a Vite plugin that turns TypeScript code into an inline <script> tag embedded in prerendered HTML, so that critical work runs before the main JavaScript bundle is loaded.

  • Importing a module with ?as-critical-script produces a React component, and the inline script is embedded when that component is rendered to HTML at build time.
  • Write it in TypeScript and it is type-checked at compile time. esbuild compiles and minifies the result, keeping the inline script as small as possible.
  • It is built for work whose value depends on timing, such as API prefetching, resource preloading, webview native bridges, and LCP optimization.
  • The outputSizeLimit option, 8192 bytes by default, caps the inline script at build time and fails the build when the limit is exceeded.
  • It works with Vite-based React frameworks that prerender HTML, including react-router in framework mode and @tanstack/react-start.
  • It is used in production on major Baemin webview screens, where this API prefetch pattern cut LCP by 30~40% against the previous implementation.

Installation

npm install -D @woowabros/vite-plugin-critical-script
# or
yarn add -D @woowabros/vite-plugin-critical-script
# or
pnpm add -D @woowabros/vite-plugin-critical-script

Example

// home.critical.ts
performance.mark('critical-start')
window.__home = fetch('/api/home').then((r) => r.json())
// home.tsx
import CriticalScript from './home.critical?as-critical-script'

export default function Home() {
  return (
    <>
      <CriticalScript />
      <Page />
    </>
  )
}
<!-- built HTML -->
<script data-size="98">(()=>{performance.mark("critical-start");window.__home=fetch("/api/home").then(e=>e.json());})();</script>

Documentation

The full documentation, including a benchmark you can run in your browser, is published at https://woowabros.github.io/critical-script.

Contributors

We welcome contributions from everyone in the community. Read our Contributing Guide to familiarize yourself with the development process, how to suggest bug fixes and improvements, and the steps for building and testing your changes.

License

MIT © Woowabros. See LICENSE for details.