Skip to content

Instantly share code, notes, and snippets.

@sbalko sbalko/index.html
Created Mar 16, 2016

Embed
What would you like to do?
Asynchronously loading first jQuery and then the Clipchamp API
<html>
<head>
<script async src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
</head>
<body>
<!-- Build up your initial document statically here. -->
<script type="text/javascript">
(function waitFor(condition, callback) {
(function poll() {
if (condition()) return callback();
else setTimeout(poll, 100);
})();
})(function() {
return typeof $ === 'function';
}, function() {
$('body').append('<script src="https://api.clipchamp.com/YOUR_API_KEY/button.js"></script>');
waitFor(function() {
return !!$.clipchamp;
}, function() {
// use the Clipchamp API with jQuery here
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.