Latest Javascript Tutorials and How-To's

javascript

Detecting First Contentful Paint (FCP) in Javascript

First contentful paint (FCP) marks the time when browser renders some content for the given document. FCP can be captured in native JavaScript using PerformanceObserver & Paint Timing API.
December 23, 2020
javascript

How usefulangle.com Improved Its Largest Contentful Paint (LCP)

This article describes how usefulangle.com improved the LCP web vital metric when there was a hero image in the page.
December 21, 2020
javascript

Detecting If Adblocker Extensions Are Blocking Ads

A possible way of detecting adblockers is to listen to the onerror event of the ad serving script element. If the script fails to load, probably it has been blocked by an adblocker.
December 20, 2020
javascript

Get Form Input Fields As Query String in Javascript

Input fields inside a form can be retrieved as a query string using FormData & URLSearchParams objects.
December 20, 2020
javascript

Dynamically Loading Multiple Scripts in Sequence

Multiple Javascript files can be loaded dynamically and executed in a given order by creating script element for each of them, and inserting them to the DOM in order of their intended execution.
December 18, 2020
javascript

Javascript Const Objects - Can They Be Changed ?

Properties and methods be changed for a const object. It just means that the variable identifier cannot be reassigned.
December 14, 2020
javascript

How to Remove Event Listeners in Javascript

Events can be removed in Javascript using the removeEventListener() method. However few other things need to be done in order to remove the event successfully
December 14, 2020
javascript

Add Event to Multiple Elements By Class in Javascript

Events can be added to multiple elements that are selected by class by looping through the list of elements and registering event for each element individually.
December 13, 2020
javascript

Chrome Extension - How to Scrape Data from a List of Pages

This tutorial explains how to create a Google Chrome extension that will navigate through a list of given URLs, and save data from each page to a file.
December 8, 2020
javascript

Creating One Time Executing Events in Javascript

One-time executing events can be created by setting the once option as parameter to addEventListener() method.
December 8, 2020
html

Open Links in a New Tab, Or Re-Use Already Existing Tab

To ensure only a single new tab or window is created for several links in the page, the same child attribute needs to set for all the links.
November 27, 2020
javascript

Measuring Site Analytics with Javascript - Page Views & Bounce Rate

This tutorial explains how to measure site analytics (page views & bounce rate) using custom Javascript, rather than using third party analytics libraries.
September 28, 2020
javascript

Measuring Site Analytics with Javascript - Sessions

This tutorial explains how to measure site analytics (sessions) using Javascript, rather than using third party analytics libraries.
September 15, 2020
javascript

Javascript Logical Nullish Assignment Operator

The logical nullish assignment operator (??=) works like the assignment operator (=) but assigns only when the left-hand side is a nullish value.
August 7, 2020
javascript

Javascript Logical AND Assignment Operator

The logical AND assignment operator represented by &&= works like the assignment operator (=), but assigns only when the left-hand side is a truthy value.
August 3, 2020
javascript

Javascript Logical OR Assignment Operator

The logical OR assignment operator (||=) works like the assignment operator (=), but assigns only when the left-hand side is a falsy value.
August 1, 2020
javascript

Checking for a Sub-String in Javascript - All Possible Cases

Javascript provides multiple methods that can check whether a sub-string is contained in a string, depending on various possible use-cases.
June 9, 2020
javascript

How to Check If a Javascript Function Was Called Using new Operator

The new.target property can be used to detect whether a function was invoked as a constructor using the new operator, or just called normally.
May 20, 2020
javascript

File Uploading Progress in Javascript Fetch

Currently it is not possible to get file upload progress for fetch. The alternate solution for now is to use XMLHttpRequest.
May 16, 2020
javascript

How to Check If Element is Visible / Hidden in Page using Intersection Observer

Checking whether an element is visible or hidden in the full page, even through it may not be in screen view, can be done through an Intersection Observer. The trick is to set the root element to document.documentElement.
May 14, 2020