Git Product home page Git Product logo

jquery-fontspy.js's Introduction

jQuery-FontSpy.js

Style your @font-face elements while they load or upon catastrophic failure.

This works by checking the change in width of a string. Comic-Sans is used as the font to compare against as it is the most "unique" default font. Using a very large font-size, we are able to determine even the slightest change. When the width of the string changes, we know that the custom font-face file has been loaded and applied.

Apply it to your project

.bannerTextChecked {
		font-family: "Lobster";
		/* don't specify fallback font here, do this in onFail class */
}

$(document).ready(function() {

	$('.bannerTextChecked').fontSpy({
		onLoad: 'hideMe',
		onFail: 'fontFail anotherClass'
	});

});

Remove that FOUC!

.hideMe {
	visibility: hidden !important;
}

.fontFail {
	visibility: visible !important;
	/* fall back font */
	/* necessary styling so fallback font doesn't break your layout */
}

jquery-fontspy.js's People

Contributors

generalhenry avatar

Watchers

Dylan Greene avatar Vlad Yazhbin [twitter.com/vla] avatar Jorge Barnaby avatar Facundo Viale avatar Ignacio Perez avatar Chetan Sastry avatar Javier Segura avatar Anand Gorantala avatar  avatar Pavel Strashkin avatar David Vacca avatar Denise Fernandez avatar  avatar Thorvald Natvig avatar James Cloos avatar Tommy Marshall avatar Pablo Carriqueo avatar Ramesh Mahadevan avatar Santiago avatar Benjamin Job avatar Junbin Huang avatar David Le avatar Sonia Patel avatar  avatar dv avatar Tomás Boccardo avatar Jonathan Regeimbal avatar David Garver avatar Henry Yang avatar Adrian Fiore avatar JM avatar DJ Madeira avatar Hoang Nguyen avatar  avatar  avatar Yingda Luo avatar Rod Perkins avatar Pablo Matías Gomez avatar  avatar  avatar  avatar  avatar Yao Xiao avatar  avatar Lukas Berg avatar  avatar  avatar Aritra Sengupta avatar  avatar  avatar  avatar Shravya Thandra avatar  avatar Yixiao Lin avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.