Skip to content

Instantly share code, notes, and snippets.

@dan-cooke
Last active July 3, 2017 14:56
Show Gist options
  • Save dan-cooke/ba83a098bd34984831f66e90b4e27760 to your computer and use it in GitHub Desktop.
Save dan-cooke/ba83a098bd34984831f66e90b4e27760 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/tucokovega
'use strict';
var container = document.getElementById('container');
//create resource locally for testing
var stylesheet = '#container{background: red; width: 100px; height: 100px; display: block;}';
var sBlob = new Blob([stylesheet], { type: 'text/css' });
//get blob as a blob: url
var sBlobURL = (URL || webkitURL).createObjectURL(sBlob);
var link = document.createElement('link');
link.href = sBlobURL;
link.rel = 'stylesheet';
document.head.appendChild(link);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment