javascript

Async vs. Defer: A Simple Explanation of Script Loading

Async vs. Defer: A Simple Explanation of Script Loading

When it comes to loading JavaScript in a website, understanding how different loading methods can impact the performance and behavior of your website is important. JavaScript can be loaded in various ways, primarily using the default loading method, async, and defer. Each of these methods has its own characteristics and use cases. In this post, we’ll explore these three methods to help you make informed decisions for your projects. Default Loading By default, JavaScript files are loaded synchronously when included in an HTML document. This means that the browser will pause parsing the HTML document to download and execute the…
Read More
AWS Conceptual guidelines

AWS Conceptual guidelines

To get a good understanding of AWS, you don’t need to master every service. Focus on a core set of services that cover the main areas of cloud computing, as this will give you a solid foundation to build from. Here’s a breakdown of key AWS services and concepts to focus on for a strong understanding: Core Compute Services EC2 (Elastic Compute Cloud): Learn how to launch, configure, and manage virtual machines. Elastic Load Balancer (ELB): Understand load balancing and how to distribute traffic across multiple instances. Auto Scaling: Explore automatic scaling based on demand to maintain application availability. Lambda:…
Read More
Implement reCAPTCHA in htmx + expressjs

Implement reCAPTCHA in htmx + expressjs

Let's start with the most obvious question, why we need it? because reCAPTCHA is using advance risk analysis techniques to detect frau, thus protecting your websites or mobile app from fraudulent activities and security risks such as: Spam. Abuse. Credential stuffing1. Account takeover (ATO). Automated account creation. Password breach. Leak detection. Here we wana use Google's reCAPTCHA which I believe is the most popular out there: It has: Mobile app SDKs. Multi-factor authentication (MFA). It interacts with your: Backend. Clients (web pages or mobile applications). UX -- User journey So here is how our users probably use our app, well…
Read More
Top 5 Game-Changing JavaScript Features in ECMAScript 2024: Boost Your Code Like Never Before!

Top 5 Game-Changing JavaScript Features in ECMAScript 2024: Boost Your Code Like Never Before!

1. Top-Level await – Async Simplified! Gone are the days when async code required wrapping everything in functions. With top-level await, we can directly use await in modules without needing an async function wrapper. This feature is particularly handy for simplifying code and reducing boilerplate Before top-level await, fetching data required an async function: async function fetchData() { const response = await fetch('https://api.example.com/data'); const data = await response.json(); return data; } fetchData(); Enter fullscreen mode Exit fullscreen mode Now, with top-level await, we can call await at the root level: const response = await fetch('https://api.example.com/data'); const data = await response.json();…
Read More
Installing And Running NPM Packages Using The Terminal

Installing And Running NPM Packages Using The Terminal

When working on a JavaScript project, chances are you'll need to install and use npm (Node Package Manager) packages. npm is essential for managing libraries and tools that enhance your development process. If you're new to this, here's a step-by-step guide to installing and running npm packages using the terminal. PrerequisitesInstall Node.js: Ensure that the recent version of Node.js is installed on your machine, as npm comes bundled with it. You can check if it's installed by running: and If you don't have it installed, download it from https://nodejs.org/https://nodejs.org/ and follow the installation instructions. After confirming it is successfully installed,…
Read More
Experiences and Caveats of Svelte 5 Migration

Experiences and Caveats of Svelte 5 Migration

I have recently updated a rather complex web application. The application has features like auth, Stripe, i18n, dark/light mode, PWA, etc. Overall, it has around 30 pages and components, with almost no third-party npm packages. I would like to point out what I found quite challenging when migrating the app to Svelte 5. Auto-Migration Script Hammer The auto-migration script provided by Svelte can do the job for you with this "one-liner" command in the terminal npx sv migrate svelte-5 (after you do all the necessary updates and installs: "@sveltejs/vite-plugin-svelte": "^4.0.0" and "svelte": "^5"). But I do not recommend this "hammer"…
Read More
Building a High-Quality Stock Report Generator with Node.js, Express, and OpenAI API

Building a High-Quality Stock Report Generator with Node.js, Express, and OpenAI API

In this article, we will delve into creating a professional-grade stock report generator using Node.js, Express, and the OpenAI API. Our focus will be on writing high-quality, maintainable code while preserving the integrity of the prompt messages used in the OpenAI API interactions. The application will fetch stock data, perform sentiment and industry analysis, and generate a comprehensive investment report. Table of Contents Project Overview Setting Up the Environment Creating the Express Server Fetching and Processing Data Integrating with OpenAI API Generating the Final Report Testing the Application Conclusion Project Overview Our goal is to build an API endpoint that…
Read More
How to Create PDFs in React from JSON Data with jsPDF

How to Create PDFs in React from JSON Data with jsPDF

This article will show how to create PDF in JS/React from JSON data. As developers, we must integrate PDF generation within the application. So, in this article, we will discuss creating PDFs using jspdf. So, Let’s get started. We will use a React environment specifically for this article. I assume you’re familiar with JavaScript/React and have already set up the React environment Before diving in, we need some sample data to generate the PDF. We’ll create a method to generate this data. const generateUsers = (count) => { const users = []; for (let i = 1; i <= count;…
Read More
How to Validate Upload and Download in Cypress

How to Validate Upload and Download in Cypress

Introduction Handling file uploads and downloads are common scenarios in end-to-end testing. In this post, we will explore how to handle both file uploads and downloads using Cypress. Even though Cypress lacks built-in support for these operations, you can achieve this functionality by leveraging a few libraries and Cypress’s robust set of commands. By the end of this guide, you'll know how to: Upload files using Cypress. Validate successful file uploads. Download files and validate their content in Cypress. Prerequisites To follow along with the examples, ensure you have Cypress installed and set up. If you're using Cypress v13.6.2, it’s…
Read More
A Simple, mostly CSS code editor

A Simple, mostly CSS code editor

In this article, I'm going to talk about how to make a very simple, browser based code editor using mostly CSS. I originally built this when I needed to let users edit JSON in a CMS that I was building. If you just want to jump to the code and the working example, here you go. The code can be found here and the working example here Contenteditable sucks... So if you were ever pondered building your own code editor, you have probably looked at contenteditable. While contenteditable is great for many situations, there is one huge problem in regards…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.