How to Loop Over DOM Elements using querySelectorAll

TL;DR: Utilize the for..of loop to iterate through DOM elements obtained from querySelectorAll. The querySelectorAll() method, when executed on the document, provides a collection of DOM elements that match the given selector(s). Keep in mind that this method does not return an array, but a NodeList object. To traverse through the resulting collection, a straightforward approach is to use the for..of loop: for (const item of document.querySelectorAll('.buttons')) { //...perform actions here } By employing this loop, you can easily access and manipulate each DOM element as necessary....

How to Maintain Sanity while Working from Home

Expert advice from a seasoned remote worker As a senior developer with over 10 years of remote working experience, I have learned a thing or two about successfully navigating the challenges of working from home. Whether you’re new to remote work or looking for ways to stay productive, here are some tips to help you maintain your sanity and thrive in your home office. Create a Dedicated Office Space: Having a designated area for work can be incredibly helpful in minimizing distractions....

How to Make a CMS-based Website Work Offline

This case study explores how I added the capability for a website to work offline using Grav, a PHP-based CMS for developers. I achieved this by introducing a set of technologies known as Progressive Web Apps, specifically Service Workers and the Cache API. First Approach: Cache-First Initially, I decided to use a cache-first approach. In this approach, when a fetch request is intercepted by the Service Worker, it first checks if the requested data is already cached....

How to Make a Page Editable in the Browser

Have you ever needed to quickly make changes to a webpage directly in your browser? There’s a hidden gem known as “design mode” that allows you to do just that. With design mode enabled, you can edit the content of the page right from within the browser itself. This is incredibly useful for testing prototypes or experimenting with different design elements. So, how do you enable design mode? It’s actually quite simple....

How to Make a Table Responsive Using CSS

Tag: CSS, responsive design, mobile usability A few days ago, I received a warning from the Google Search Console regarding a Mobile Usability issue on a page that contained a large table. Not only did this poor rendering make for a bad user experience, but it also resulted in an error in the Google Search Console. As a senior developer, I knew I had to find a solution to this problem....

How to Make an Editable Checked Checkbox in React

In this blog post, we will discuss how to add a checkbox in a React component that is checked by default but editable by the user. Initially, I had a simple checkbox in my React component: <input name="enable" type="checkbox" /> However, setting a checked attribute with the value of "checked" didn’t work as expected. The checkbox state remained unchangeable. To resolve this issue, I discovered that the defaultChecked attribute should be used instead:...

How to Make an HTTP POST Request using Node

Learn how to make an HTTP POST request using Node.js. There are multiple options available, depending on the level of abstraction you prefer. The simplest way to perform an HTTP POST request in Node.js is by using the Axios library. Here’s an example: const axios = require('axios'); axios.post('/todos', { todo: 'Buy the milk', }) .then((res) => { console.log(`statusCode: ${res.statusCode}`); console.log(res); }) .catch((error) => { console.error(error); }); Another option is to use the Request library....

How to Make Responsive JSX in React

I recently had the need to create a responsive sidebar in React that appears differently on large screens compared to smaller screens. In order to achieve this, I wanted to find a way to detect changes in responsive layouts in JSX. To accomplish this, you can use the react-responsive package. First, install the package using npm: npm install react-responsive Then, import the useMediaQuery hook into your components: import { useMediaQuery } from 'react-responsive'; You can use the useMediaQuery hook like this:...

How to Make the Jump and Become a Developer

Making the transition from learning programming to becoming a developer can be challenging, but with the right approach, it is achievable. In this post, I will provide some guidance on how to navigate this journey. Start with a Course or Tutorial Begin your coding journey by taking a course or following tutorials. This can be in the form of video courses or YouTube tutorials. As you progress, start building simple applications and gradually move towards more complex ones....

How to Make Your S3 Buckets Public

I recently wrote a tutorial on how to upload an image to S3, but I encountered an issue when the uploaded image couldn’t be accessed publicly in read mode. If you’re facing the same problem, don’t worry. I’ll guide you through the steps to make your S3 buckets public. First, let’s talk about the “Block public access” setting. Disabling this block alone doesn’t make your images accessible to the public. So, what should you do?...