UNPKG

fontfaceonload

Version:

A simple utility to execute a callback when a webfont loads.

31 lines 895 B
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> <!-- The text url param is used to prevent `latin-ext` from being included in the Google Font (FontFaceOnload does not match based on `unicde-range`). --> <link href="https://fonts.googleapis.com/css?family=Raleway:400&text=This%20text%20will%20have%20the%20new%20font%20applied." rel="stylesheet"> <style> p { font-family: monospace; } .raleway p { font-family: Raleway, monospace; } </style> </head> <body> This text will have a default font applied. <p>This text will have the new font applied.</p> <script src="../dist/fontfaceonload.js"></script> <script> FontFaceOnload( "Raleway", { success: function() { document.documentElement.className += " raleway"; alert( "Success!" ); } }) </script> </body> </html>