Last active
August 26, 2016 18:50
-
-
Save octavioturra/accd30b6b7af7da01b835ece09758401 to your computer and use it in GitHub Desktop.
function to load Workers on-the-fly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getFunctionURL = (f) => URL.createObjectURL(new Blob(['(', f.toString(),')()'], {type: 'text/javascript'})); | |
const toWorker = (f) => new Worker(getFunctionURL); | |
const toServiceWorker = (f, opt = {}) => navigator.serviceWorker && navigator.serviceWorker.register(f, opt); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment