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

@frontlabsofficial/google-fonts-fetch

v1.0.2

Published

A lightweight utility for seamlessly integrating Google Fonts into web projects, optimizing web performance, and enhancing user experience.

Downloads

731

Readme

@frontlabsofficial/google-fonts-fetch

Description

@frontlabsofficial/google-fonts-fetch is a lightweight and efficient package designed to simplify the process of self-host Google Fonts. By leveraging this package, developers can effortlessly download Google Fonts to their local environment, enabling seamless integration and improved website performance.

Motivation

While working on improving PageSpeed, I discovered the significant enhancements brought by Google Fonts v2. Everything seemed to become smoother and lighter, from font sizes to the ability to reuse various font weights. Despite my efforts to find a suitable API or package for immediate use, I came up empty-handed.

For instance, take the font Roboto. The font sizes of version 1 compared to version 2 were ~130kb and ~11kb respectively. Different font weights could be utilized within a single file. The savings were substantial, sparking a strong inspiration within me to create this package. It's evident that this project has the potential to make a substantial impact on metrics such as FCP, LCP, and overall PageSpeed scores, significantly benefiting your website.

This project aims to harness the efficiencies of Google Fonts v2, offering a streamlined solution for integrating fonts into web projects. By optimizing font usage, we can enhance website performance and user experience, ultimately leading to improved rankings and user engagement.

Features

  • Effortless Font Download: Quickly fetch and download Google Fonts to your local project directory with minimal configuration.

  • Customizable Options: Customize font selection, variants, and subsets to tailor the download to your specific project needs.

  • Optimized Performance: Reduce page load times and enhance website performance by serving fonts directly from your server.

Installation

npm install @frontlabsofficial/google-fonts-fetch

Usage

Create Google Fonts Fetch

import { createGoogleFontsFetch } from '@frontlabsofficial/google-fonts-fetch'
const fetch = createGoogleFontsFetch({
  base: 'https://test.com',
  metadata: {
    name: 'metadata.json',
    override: false,
    outputPath: path.resolve('.output/metadata'),
  },
  outputPath: path.resolve('.output'),
  css: {
    write: true,
    combie: true,
  },
  font: {
    outputPath: path.resolve('.output/fonts'),
  },
})

Download single font

fetch.single('Roboto')
fetch.single('Roboto', { weight: [400] })

Download multiple fonts

fetch.multiple([
  { name: 'Roboto' },
  { name: 'Open Sans' },
])

fetch.multiple([
  { name: 'Roboto', weight: [400] },
  { name: 'Open Sans', weight: [400, 500] },
])

Download all fonts

fetch.all()

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.