Add a badge to the browser tab favicon using JavaScriptArticle contains
  1. Understanding what a favicon is
  2. Use cases for the badge in the favicon
  3. Adding a badge to your browser tab favicon with JavaScript
  4. I can't change the favicon with JavaScript in Safari
  5. Taking it to the next level with an enhanced version
    1. Implementing favicon caching
    2. Framework integration
    3. Real-world examples
  6. Alternative approaches
Example of browser tab with favicon and badge on it

Add a badge to the browser tab favicon using JavaScript

Adding a badge to the favicon using JavaScript can be done by updating the image specified by the <link /> element with a new icon image.

This method involves JavaScript and creating an in-memory canvas element, applying the favicon image, drawing the badge shape and text on top, and then updating the <link /> element’s href attribute with the final composite of the canvas element’s image data as a Base64 encoded string.

Continue reading “Add a badge to the browser tab favicon using JavaScript”
Check if a string is valid HTML using JavaScriptArticle contains
  1. Key considerations
  2. Essential requirements
  3. How does the DOMParser interface parse HTML strings differently based on the mimeType argument?
  4. Practical example
  5. Code
  6. Example of validation error
  7. What a MIME type is and why it's used in the isStringValidHtml function?
  8. How does the DOMParser API handle invalid HTML syntax?
  9. How can you ensure that HTML string validation in JavaScript correctly detects missing or misplaced tags?
    1. 1. Mechanical check - is every tag balanced?
    2. 2. Semantic check - did the browser mutate the DOM?
    3. 3. One-line validator
    4. 4. Server-side (Node.js) usage
  10. Summary
Keyboard with all empty keys except four keys: H, T, M, and L next to each other.

Check if a string is valid HTML using JavaScript

There isn’t a single definitive way to determine if a string is valid HTML, as HTML itself is flexible and can be malformed. However, we can use various methods to check for the presence of HTML-like structures in a string.

One method is to use DOMParser API and its method parseFromString.

The DOMParser API interface allows you to parse XML or HTML source code from a string and convert it into a DOM Document. It is used to convert a string of XML or HTML into a structured DOM object that can be easily manipulated using JavaScript.

Continue reading “Check if a string is valid HTML using JavaScript”
Solution to "Type 'FileList' must have a '[Symbol.iterator]()' method that returns an iterator"Article contains
  1. Solution to the error Type 'FileList' must have a '[Symbol.iterator]()' method that returns an iterator
  2. Notes
How to pause and resume event propagation in JavaScript?Article contains
  1. How to pause and resume events in JavaScript
  2. Support for asynchronous operations during event propagation pause
  3. Techniques for pausing and resuming event propagation
  4. Implementing event pausing and resuming in JavaScript
  5. Implementing event pausing and resuming on input type file
Reporting bug practicesArticle contains
  1. How do we define a bug?
  2. Submitting bugs
  3. When reporting a bug, what information should be included
  4. Choose a non-generic subject describing what and where is failing
  5. Use plain English, don't use words that only a few might understand
  6. Avoid acronyms
  7. Is the problem observed persistent or temporary?
  8. Actual behaviour
  9. Steps to reproduce
  10. Expected behaviour
  11. When possible, include logs, screenshots, video recordings, the app version, and any other supporting information
  12. Discussing root cause
  13. Geek and Poke fun
Create a self-signed SSL certificate and update Keychain Access on MacOSArticle contains
  1. How to create a self-signed certificate with the command line?
  2. Verify your certificate
  3. Updating Nginx configuration
Sass darken and lighten functions replace with color.adjust in Visual Studio CodeArticle contains
  1. Automatically replacing Sass darken and lighten functions with color.adjust in All Files with Visual Studio Code
  2. Important notes on the replacement process
Determining viewport size - small, medium and large - using CSSArticle contains
  1. CSS code for determining viewport size
  2. How to get the value of the viewport size
  3. Practical example of viewport size determination
Computer and mobile phone

Determining viewport size – small, medium and large – using CSS

To get the viewport size using CSS in JavaScript, you can utilize the getComputedStyle method to access the content of a pseudo-element, such as ::before, which can be defined in your CSS media queries. This allows you to dynamically determine the viewport size category (e.g., small, medium, large) based on the current screen width, enhancing responsive design capabilities.

The browser viewport is the screen that actually shows the webpage. Determining its size might be handy when we want to provide some specific features for the viewport size.

Continue reading “Determining viewport size – small, medium and large – using CSS”
What is a Single Page Application?Article contains
  1. What is the difference between Single Page Application and Multi Page Application?
  2. Benefits of Single Page Applications
  3. The Downsides of Single Page Applications
  4. SEO and crawling challenges
  5. Single page app example sites
Single Page Application

What is a Single Page Application?

A Single Page Application (SPA) is a web application or website that works within a web browser and only loads one document. It does not require page refreshing while in use, and the majority of its content remains unchanged with only minor updates.

Primary goal is to enable faster transitions and make the web application or website feel more like a native application.

Continue reading “What is a Single Page Application?”
Lazy loading CSS background images for better website loading performanceArticle contains
  1. Can you lazy load background images?
  2. Set the goals for lazy loading CSS background
  3. The solution
  4. Workable example
  5. Download package
  6. Discussions
  7. Improved lazy loading for images, video, and audio
  8. How to set lazy loading images on other libraries
Collection of pictures in frame

Lazy loading CSS background images for better website loading performance

Every single HTTP request decreases loading performance. For a simple image, the attribute loading="lazy" can be used in order to defer the loading of off-screen images until the image appears on the screen. Lazy loading of images improves performance by reducing initial page load time, initial page weight, initial page rendering, and system resource usage.

  1. Initial page load time – with lazy loading, the page is loaded faster because only images that are visible on the screen are loaded.
  2. Initial page weight – because images that aren’t visible won’t be downloaded. Hence, the whole page weight will be smaller.
  3. Initial page rendering – less images to render, the faster the whole page will be rendered for the user.
  4. System resource usage – this refers to less resource usage like CPU, network, etc.
Continue reading “Lazy loading CSS background images for better website loading performance”