lll
lll

Reputation: 476

Javascript blur works slower than focus function

I came across with an interesting firing time difference between focus and blur event listeners. I added both listeners to window and just wanted to check if both work properly. Then I realized that blur function delays approximately 0.2 seconds. When I tried to change an element color or some different DOM manupulation both works at the same time but when called console.log it has a significant difference. I have this issue with Chrome and Opera, I don't know why but Firefox doesn't have this issue.

Check the code below.

window.addEventListener('focus', () => {
  console.log("focused.");
});

window.addEventListener('blur', () => {
  console.log("blured.");
});

Upvotes: 0

Views: 191

Answers (0)

Related Questions