Archives: JavaScript

How do I detect a click outside an element?

25/04/2019 | By Dev | No Comments | Filed in: JavaScript.

You can listen for a click event on document and then make sure #dropdownmenu is not an ancestor or the target of the clicked element by using .closest(). For those who don’t want to use jQuery. Here’s the above code in plain vanillaJS (ECMAScript6). Source:

Native image lazy-loading for the web!

10/04/2019 | By Dev | No Comments | Filed in: JavaScript.

In this post, we’ll look at the new loading attribute which brings native <img> and <iframe> lazy-loading to the web!. For the curious, here’s a sneak preview of it in action: We are hoping to ship support for loading in Chrome 75 and are working on a deep-dive of the feature we’ll publish soon. Until then, let’s dive into how loading works. Introduction Web pages often contain • Read More »