Get started with when CDN
MIT licensed
Import and call library functions after page load in JS projects.
Tags:- Promises/A+
- promises-aplus
- promise
- promises
- deferred
- deferreds
- when
- async
- asynchronous
- cujo
- ender
Stable version
Copied!
How to start using when CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with when CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/when/3.7.8/when.min.js"></script>
</head>
<body>
<button id="myButton">Click me</button>
<script>
const myButton = document.getElementById('myButton');
when(
() => myButton.disabled, // condition
() => console.log('Button is disabled'),
() => console.log('Button is enabled')
).then(function() {
myButton.addEventListener('click', function() {
myButton.disabled = true;
when(
() => !myButton.disabled, // new condition
() => console.log('Button is enabled and was clicked'),
() => console.log('Button is still disabled')
).then(function() {
myButton.disabled = false;
});
});
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
All versions
0.10.0
0.10.1
0.10.2
0.10.3
0.10.4
0.11.0
0.11.1
0.9.0
0.9.1
0.9.2
0.9.3
0.9.4
1.0.0
1.0.1
1.0.2
1.0.3
1.0.4
1.1.0
1.1.1
1.2.0
1.3.0
1.4.0
1.4.1
1.4.2
1.4.3
1.4.4
1.5.0
1.5.1
1.5.2
1.6.0
1.6.1
1.7.0
1.7.1
1.8.0
1.8.1
2.0.0
2.0.1
2.1.0
2.1.1
2.2.0
2.2.1
2.3.0
2.4.0
2.4.1
2.5.0
2.5.1
2.6.0
2.7.0
2.7.1
2.8.0
3.0.0
3.0.1
3.1.0
3.2.0
3.2.1
3.2.2
3.2.3
3.3.0
3.3.1
3.4.0
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5
3.4.6
3.5.0
3.5.1
3.5.2
3.6.0
3.6.1
3.6.2
3.6.3
3.6.4
3.7.0
3.7.1
3.7.2
3.7.3
3.7.4
3.7.5
3.7.6
3.7.7
*** 3.7.8