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

pure-autosize

v0.3.0

Published

A declarative, framework-agnostic library for automatically resizing textareas that survives DOM morphing operations

Readme

Pure Autosize

A declarative, framework-agnostic library for automatically resizing textareas that survives DOM morphing operations.

Features

  • 🚀 Zero DOM mutations - Uses Constructed Stylesheets (modern browsers only)
  • 🔄 Morphing-resistant - Survives Turbo, idiomorph, and other DOM morphing operations
  • 📝 Declarative API - Simple autosize attribute
  • ⚡ Lazy loading - Optional autosize="lazy" for performance
  • 🎯 Framework-agnostic - Works with any framework or vanilla JS

Browser Support

  • Chrome 73+ (March 2019)
  • Firefox 101+ (May 2022)
  • Safari 16.4+ (March 2023)

For older browser support, consider using the classic autosize.js library.

Installation

npm install pure-autosize

Usage

Basic Usage

<!-- Automatic resizing -->
<textarea autosize></textarea>

<!-- Lazy loading (waits until visible) -->
<textarea autosize="lazy"></textarea>
import 'pure-autosize';
// That's it! The library auto-initializes and manages everything

How It Works

Pure Autosize detects content changes through multiple mechanisms:

  1. User input - Standard input events
  2. Form resets - reset event handlers
  3. Programmatic changes - Value property override
  4. Window resizing - Debounced resize handlers
  5. Dynamic elements - MutationObserver for new textareas

The library uses Constructed Stylesheets to apply height styles without DOM mutations, making it completely resistant to morphing operations that would normally interfere with inline styles.

Why Pure Autosize?

Traditional autosize libraries use inline style attributes which get overwritten during DOM morphing operations (like those used by Turbo, HTMX, idiomorph, etc.). Pure Autosize solves this by:

  • Using Constructed Stylesheets that exist in memory only
  • Detecting content changes via property overrides
  • Automatically handling all edge cases

This makes it perfect for modern applications using:

  • Turbo (Rails/Hotwire)
  • HTMX with morphing extensions
  • idiomorph
  • Phoenix LiveView
  • Any framework that morphs/replaces DOM content

API Reference

HTML Attributes

  • autosize - Enable automatic resizing
  • autosize="lazy" - Enable lazy loading (resize only when visible)

Testing

This library is thoroughly tested across all supported browsers:

npm test              # Run tests on default browser (Chrome)
npm run test:all      # Run tests on Chrome, Firefox, and WebKit
npm run test:chrome   # Test Chrome specifically
npm run test:firefox  # Test Firefox specifically
npm run test:webkit   # Test WebKit/Safari specifically

See TESTING.md for detailed testing instructions.

License

MIT License - see LICENSE file.