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

reveal.js-fontsfirst

v1.0.1

Published

A plugin for Reveal.js that makes sure that your fonts get loaded before initialising Reveal.js

Downloads

4

Readme

FontsFirst

A plugin for Reveal.js that makes sure that your fonts get loaded before initialising Reveal.js.

Sometimes when you use a Google or Typekit font, it takes some time to load the font. Your presentation will then first show in a default font and then jump to the correct font (known as a 'FOUT', a Flash Of Unstyled Text).

Also, if you use an Adblocker like Ghostery, it is possible that the remote font will also not load at all. This plugin fixes that, but you do need to provide your self-hosted fallback fonts.

Here's a demo of a simple project that uses the FontsFirst plugin.

FontsFirst works like this:

  • It uses WebFontLoader.js to load remote fonts.
  • WebFontLoader.js checks if the remote loading works.
  • WebFontLoader.js uses a timeout. If the time is up and remote fonts do not work, it provides a function in which you can provide your self-hosted fonts.
  • To avoid the timeout each time the page is reloaded, the currently set way of loading the font is saved in a sessionStorage. This is reset only if the browser is quit.
  • FontsFirst is a wrapper around WebFontloader and the sessionStorage: If either a remote font or self-hosted font is loaded, it will let Reveal.js continue loading.

Installation

The FontsFirst plugin has been rewritten for Reveal.js version 4.

If you want to use FontsFirst with an older version of Reveal, use the 1.0.0 version.

FontsFirst needs an other script to be able to function: WebFontLoader.js by Typekit/Adobe and Google. This checks the availability of the remotely hosted webfonts.

Regular installation

Copy the fontsfirst folder to the plugins folder of the reveal.js folder, like this: plugin/fontsfirst. The script for WebFontLoader is on a CDN, we add it as well.

<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<script src="plugin/fontsfirst/fontsfirst.js"></script>
<script>
    Reveal.initialize({
        //...
        plugins: [ FontsFirst ]
    });
</script>

npm installation

This plugin is published to, and can be installed from, npm.

npm install reveal.js-fontsfirst

Configuration

There are a few options that you can change from the Reveal.js options. The values below are default. It would be wise to change at least the modules and the selfhostcss options.

Reveal.initialize({
	// ...
	fontsfirst: {
		debug: false,
		modules: {
			google: {
				families: ['Roboto']
			}
		},
		selfhostcss : "/path/to/selfhostedfont.css",
		timeout: 1000
	},
	plugins: [ FontsFirst ]
});
  • debug: This option, if set to true, will report in the console what gets loaded by WebFontLoader and what gets set in the sessionStorage.
  • modules: The modules option is where you set your Google, Typekit, Fontdeck or custom font. If you keep to the syntax described at https://github.com/typekit/webfontloader, it will simply work. Just make sure that both the module and the selfhostcss refer to one font that you also use in your styling. Like this: .reveal h3 { font-family: 'Roboto'; }
  • selfhostcss : This is where you should set the path to the CSS that will point to your self-hosted fonts.
  • timeout : This is the timeout that WebFontLoader.js uses to load remote fonts. You can change it if you would like to give it some more or less time.

Like it?

If you like it, please star this repo.

License

MIT licensed

Copyright (C) 2019 Martijn De Jongh (Martino)