yett
yett copied to clipboard
Move all side effects to exported init function
I’m creating a package that uses yett under the hood and the way it requires an assigned whitelist/blacklist before the package is included makes it hard to use it with import/export because the load order can’t always be guaranteed. This pull request moves all immediate side-effects to an init
function that’s exported along with the current unblock
function. It still allows setting a whitelist/blacklist on window
but also accepts it as an argument to the init
function.
Usage before:
<script>
window.YETT_BLACKLIST = [
/script\.js$/
]
</script>
<script src="yett.min.js"></script>
Usage after:
<script src="yett.min.js"></script>
<script>
yett.init({
blacklist: [
/script\.js$/
]
})
</script>
It would be a breaking change though because nothing will happen unless init
is called. If that’s a problem there could perhaps be separate builds for browser and modules.
Tests pass.
Exactly what I had in mind when trying this superb library, hope it gets released soon 👍