Socket
Socket
Sign inDemoInstall

webfontloader

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webfontloader

Web Font Loader gives you added control when using linked fonts via @font-face.


Version published
Weekly downloads
379K
decreased by-16.99%
Maintainers
1
Weekly downloads
 
Created

What is webfontloader?

The webfontloader npm package is a JavaScript library that allows you to asynchronously load fonts from various providers such as Google Fonts, Typekit, and custom sources. It provides a way to control the loading behavior and offers events to handle different stages of the font loading process.

What are webfontloader's main functionalities?

Loading Google Fonts

This feature allows you to load fonts from Google Fonts. The code sample demonstrates how to load 'Droid Sans' and 'Droid Serif' fonts from Google Fonts.

const WebFont = require('webfontloader');
WebFont.load({
  google: {
    families: ['Droid Sans', 'Droid Serif']
  }
});

Loading Typekit Fonts

This feature allows you to load fonts from Adobe Typekit. The code sample shows how to load fonts using a Typekit ID.

const WebFont = require('webfontloader');
WebFont.load({
  typekit: {
    id: 'your-typekit-id'
  }
});

Loading Custom Fonts

This feature allows you to load custom fonts by specifying the font families and the URLs to the CSS files that define them. The code sample demonstrates how to load 'My Font' and 'My Other Font' from a custom CSS file.

const WebFont = require('webfontloader');
WebFont.load({
  custom: {
    families: ['My Font', 'My Other Font:n4,i4,n7'],
    urls: ['/fonts.css']
  }
});

Handling Font Loading Events

This feature allows you to handle events during the font loading process. The code sample demonstrates how to log messages when fonts are successfully loaded or if they fail to load.

const WebFont = require('webfontloader');
WebFont.load({
  google: {
    families: ['Droid Sans', 'Droid Serif']
  },
  active: function() {
    console.log('Fonts are active');
  },
  inactive: function() {
    console.log('Fonts could not be loaded');
  }
});

Other packages similar to webfontloader

Keywords

FAQs

Package last updated on 26 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc