Skip to content

Instantly share code, notes, and snippets.

@idevN
idevN / converts-webfont-to-base64.js
Created June 8, 2017 07:02 — forked from arielsalminen/converts-webfont-to-base64.js
Convert Google WOFF font to base64 format and inline to <head> of document
// Get binary file using XMLHttpRequest
function getBinary(file) {
var xhr = new XMLHttpRequest();
xhr.open("GET", file, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send(null);
return xhr.responseText;
}
// Base64 encode binary string