Skip to content

Instantly share code, notes, and snippets.



Created Mar 23, 2017
What would you like to do?
Blinking caret that sleeps the main thread for 500ms
<!DOCTYPE html>
#caret {
height: 16px;
width: 1px;
background: black;
will-change: opacity;
opacity: 1;
transition: opacity;
transition-duration: 500ms;
<div id="caret"></div>
var caret = document.getElementById("caret");
function blink() {
var opacity =; = (opacity == "1") ? "0" : "1";
setTimeout(blink, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment