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

fittext.js

v1.2.0

Published

FitText makes font-sizes flexible. Use this plugin on your responsive design for ratio-based resizing of your headlines.

Downloads

2,005

Readme

FitText.js, a jQuery plugin for inflating web type

FitText makes font-sizes flexible. Use this plugin on your responsive design for ratio-based resizing of your headlines.

How it works

Here is a simple FitText setup:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.fittext.js"></script>
<script>
  jQuery("#responsive_headline").fitText();
</script>

Your text should now fluidly resize, by default: Font-size = 1/10th of the element's width.

The Compressor

If your text is resizing poorly, you'll want to turn tweak up/down "The Compressor". It works a little like a guitar amp. The default is 1.

jQuery("#responsive_headline").fitText(1.2); // Turn the compressor up   (resizes more aggressively)
jQuery("#responsive_headline").fitText(0.8); // Turn the compressor down (resizes less aggressively)

This will hopefully give you a level of "control" that might not be pixel perfect, but resizes smoothly & nicely.

minFontSize & maxFontSize

FitText now allows you to specify two optional pixel values: minFontSize and maxFontSize. Great for situations when you want to preserve hierarchy.

jQuery("#responsive_headline").fitText(1.2, { minFontSize: '20px', maxFontSize: '40px' });

CSS FAQ

  • Make sure your container has a width!
    • display: inline elements don't have a width. Use display: block OR display: inline-block+ a specified width (i.e. width: 100%).
    • position:absolute elements need a specified width as well.
  • Tweak until you like it.
  • Set a No-JS fallback font-size in your CSS.

Don't use jQuery?

That's okay. Check out these handy non-jQuery versions maintained by other people.

Changelog

  • v 1.2 - Added onorientationchange event
  • v 1.1 - FitText now ignores font-size and has minFontSize & maxFontSize options
  • v 1.0.1 - Fix for broken font-size.
  • v 1.0 - Initial Release

In Use:

If you want more exact fitting text, there are plugins for that! We recommend checking out BigText by Zach Leatherman or SlabText by Brian McAllister.

Download, Fork, Commit.

If you think you can make this better, please Download, Fork, & Commit. We'd love to see your ideas.