Latest Javascript Tutorials and How-To's
javascript
What Happens to setTimeout() / setInterval() Timers Running on Inactive Browser Tabs ?
Time delay for setTimeout() / setInterval() methods executing on inactive browser tabs are set to one second regardless of their value defined in code.
December 15, 2019
ui-ux
How to Disable Page Scrolling when Modal Dialog is Opened
When a fixed-position modal dialog is opened, scrollbars on the page can be removed by dynamically setting overflow:hidden CSS for the 〈body〉tag.
December 15, 2019
javascript
Preventing Addition of New Properties to a Javascript Object with Object.seal()
The Object.seal() method seals an object. After an object gets sealed, no new properties can be added to it.
December 12, 2019
javascript
Preventing Changes to a Javascript Object with Object.freeze()
The Object.freeze() method can make an object or array immutable. No changes can be made to that object once it gets immutable.
December 11, 2019
javascript
Hashbang Comments - The Third Way of Adding Comments in Javascript Code
Hashbang comments is the third type of syntax for adding comments to Javascript code. This comment can specify the Javascript interpreter that is to be used to execute the code within a script file or a module.
December 9, 2019
html
Loading CSS Stylesheet on Demand Through Its disabled Attribute
A stylesheet can include the disabled attribute in its markup to prevent it from being downloaded on page load. Later when the stylesheet needs to loaded on demand, its disabled attribute can be removed with Javascript.
December 3, 2019
javascript
Numeric Separators in Javascript to Improve Readability of Large Numbers
Numeric separators can be used to improve readability of large numbers. For example the number 111111111111111111111111, which is difficult to read, can be alternately written as 111_111_111_111_111_111_111_111
December 2, 2019
javascript
Detecting Change in Playing Subtitles Text for 〈video〉Element
Sometimes we would like to detect when the subtitles change in the playing video. This can be done by listening to the cuechange event on the 〈track〉element.
November 30, 2019
javascript
Preserving Context of this Inside AJAX Response Callbacks in jQuery
It is very common to access current this context inside jQuery AJAX's response callbacks (success or error). This tutorial describes 3 ways of doing this.
November 29, 2019
javascript
Checking whether Page is Opened / Active in Browser Tab
The Page Visibility API can be used to check whether a browser tab is active or not, i.e. if the page is in view or hidden from view.
November 25, 2019
resources
How to Load Google Fonts with JavaScript
Google Fonts can be loaded through Javascript using the Web Font Loader Library. Events are also triggered when fonts are being loaded, or when they are rendered.
November 19, 2019
javascript
Converting Timestamp to Date & Time in Javascript
A UNIX timestamp can be converted to the required date and time formats in Javascript using the Date() object and its methods.
November 18, 2019
javascript
Looping through querySelectorAll() with Javascript
List of nodes returned by querySelectorAll() can be looped through using the forEach() method of the returned NodeList object.
November 16, 2019
javascript
Differences between 〈script type=module〉and〈script〉
Whenever a Javascript module needs to be applied to HTML, we need to do it within a 〈script type=module〉 tag. However there are some difference in Javascript execution in this tag vs a normal 〈script〉tag.
November 15, 2019
javascript
How to Loop through〈select〉Options with Javascript
Options of a dropdown select element can be looped over its options property. This property gives a list of all option elements inside it.
November 13, 2019
javascript
What is script type=module ?
A script tag having type=module attribute specifies that it to be considered as a Javascript module. It may be importing other Javascript module(s) inside it and becomes a top-level module for the imported modules.
November 10, 2019
javascript
How to Prevent Disqus Comments System from Slowing Page Speed & Performance
Loading Disqus' script files and comments on page load can lower down speed and performance of the page, specially in mobiles. A solution would be to use an Intersection Observer to lazily load Disqus.
November 10, 2019
javascript
How to Detect Number of Processor Cores with Javascript
The number of available logical processor cores in the device can be found with the navigator.hardwareConcurrency Javascript property. This number can be useful in knowing how many Web Workers can be executed in parallel.
November 6, 2019
javascript
Javascript KV Storage Introduction Tutorial
KV Storage API is an asynchronous way to save data in the browser using Javascript Promises. Its asynchronous nature guarantees that the performance of the application is not impacted.
November 4, 2019
javascript
How to write Immediately-invoked / Anonymous Async Functions (IIFE)
An anonymous async function can be defined using the Immediately-invoked Function Expression pattern for asynchronous functions.
November 2, 2019
New & Upcoming Javascript / Web Platform Features
Pan / Tilt / Zoom Support for Camera in getUserMedia()
Javascript Logical Assignment Operators
Intersection Observer Now Also Accepts a Document as the Root Element
Javascript String.replaceAll() Method
Better Caching With stale-while-revalidate Directive in Cache-Control Header
Synchronous AJAX Will Not Work in Page Dismissal Events
Javascript globalThis Property
Javascript Hashbang Comment Syntax