stylus-standalone

raw JSON →
0.1.0 verified Fri May 01 auth: no javascript abandoned

Stylus-standalone is a standalone browser-ready build of the Stylus CSS preprocessor, allowing you to compile Stylus code directly in the browser without Node.js or a build step. Version 0.1.0 is the initial release, and the package appears to be experimental with no further updates. It provides a single script tag inclusion via CDN, making it easy to experiment with Stylus in HTML. However, it lacks TypeScript definitions, active maintenance, and common developer tooling. Compared to the official stylus package, this is a minimal wrapper that exposes the compiler globally, suitable only for quick prototyping or educational use.

error stylus is not defined
cause Script tag not loaded before usage.
fix
Ensure <script src="https://unpkg.com/stylus-standalone"></script> is placed before your code.
error Cannot read property 'render' of undefined
cause Trying to use stylus as a function without proper invocation.
fix
Use stylus.render() directly, not stylus().render().
error TypeError: callback is not a function
cause Missing callback argument in render call.
fix
Always provide a callback: stylus.render(str, opts, (err, css) => {...})
gotcha The package is not maintained and may not work with modern browsers.
fix Consider using the official stylus package with a build tool.
breaking Callback-based API only; promises not supported.
fix Wrap calls in a promise: new Promise((resolve, reject) => stylus.render(str, opts, (e,r) => e ? reject(e) : resolve(r)))
deprecated Package likely uses outdated stylus version and may have unpatched security issues.
fix Use stylus package via npm instead.
npm install stylus-standalone
yarn add stylus-standalone
pnpm add stylus-standalone

Demonstrates in-browser Stylus compilation using a script tag and the global stylus object with callback.

<!DOCTYPE html>
<html>
<head>
  <script src="https://unpkg.com/stylus-standalone"></script>
</head>
<body>
  <script>
    const stylusCode = `
      body
        font-family sans-serif
        color #333
    `;
    stylus.render(stylusCode, { compress: true }, (err, css) => {
      if (err) console.error(err);
      else {
        const style = document.createElement('style');
        style.textContent = css;
        document.head.appendChild(style);
      }
    });
  </script>
</body>
</html>