If you do it too early, you get the error Uncaught ReferenceError: filepicker is not defined
.
I'm using this code from https://developers.filepicker.io/docs/web/ to load it:
For advanced users, if you want to load the javascript in a non-blocking fashion, you can use this instead:
<script type="text/javascript">
(function(a){if(window.filepicker){return}var b=a.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===a.location.protocol?"https:":"http:")+"//api.filepicker.io/v1/filepicker.js";var c=a.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c);var d={};d._queue=[];var e="pick,pickMultiple,pickAndStore,read,write,writeUrl,export,convert,store,storeUrl,remove,stat,setKey,constructWidget,makeDropPane".split(",");var f=function(a,b){return function(){b.push([a,arguments])}};for(var g=0;g<e.length;g++){d[e[g]]=f(e[g],d._queue)}window.filepicker=d})(document);
</script>
I can't figure out how to know when it is loaded so that I can call filepicker.setKey(). A work-around is to call it every time I use the filepicker, but that seems lame.