Search
Adding Vite to Your Existing Web App
11.1.2022
Vite (pronounced “veet”) is a newish JavaScript bundler. It comes batteries-included, requires almost no configuration to be useful, and includes plenty of configuration options. Oh—and it’s fast. Incredibly fast.
This post will walk through the process of converting an existing …
Adding...
CSS-Based Fingerprinting
3.1.2022
Fingerprinting is bad. It’s a term that refers to building up enough metadata about a user that you can essentially figure out who they are. JavaScript has access to all sorts of fingerprinting possibilities, which then combined with the IP …
CSS-Based Fingerprinting originally...
JavaScript S
27.12.2021
Replacing a substring of text within a larger string has always been misleading in JavaScript. I wrote Replace All Occurrences of a String in JavaScript years ago and it’s still one of my most read articles. The confusion lies in that replace only replaces the first occurrence of a substring...
Why Ember?
22.12.2021
There was a time when I’d write React, Angular, and Ember as a kind of generic grouping of three major JavaScript frameworks. And maybe just because three is a nice number, that became React, Vue, and Angular over time, thanks …
Be Prepared for Failure and Handle it Gracefully
20.12.2021
When I was working at my first “real” job in the field in the mid-2000s, it was hammered in the web dev field to build tiny websites (no more than 100KB per page), only use JavaScript for special effects, and …
navigator.clipboard API
13.12.2021
Reading from and writing to the user’s clipboard can be both a very useful and dangerous capability. Used correctly and it’s a huge convenience to the user; used dubiously and the user could suffer catastrophic consequences. Imagine a wrong account number or wallet address being copied...
Eye Droppin’
9.12.2021
Quick hits! There is a new web API called EyeDropper:
if ('EyeDropper' in window) {
const eyeDropper = new EyeDropper();
try {
// This has gotta be triggered by a user interaction,
// so consider this pseudo-code.
const result …
The Invisible JavaScript Backdoor
8.12.2021
An interesting (scary) trick of an nearly undetectable exploit. Wolfgang Ettlinger:
What if a backdoor literally cannot be seen and thus evades detection even from thorough code reviews?
I’ll post the screenshot of the exploit from the post with the …
The Many Faces of VS Code in the Browser
18.11.2021
VS Code is built from web technologies (HTML, CSS, and JavaScript), but dare I say today it’s mostly used a local app that’s installed on your machine. That’s starting to shift, though, as there has been an absolute explosion of …
The post The Many Faces of VS Code in...
Array.prototype.at
8.11.2021
Working with arrays is an essential skill in any programming language, especially JavaScript, as we continue to rely on external data APIs. JavaScript has added methods like find and `findIndex recently, but one syntax I love from languages like Python is retrieving values by negative indexes. When...
Proxying Third-Party JavaScript as First-Party JavaScript (and the Potential Effect on Analytics)
2.11.2021
First, check out how incredibly easy it is to write a Cloudflare Worker to proxy another URL:
addEventListener("fetch", (event) ={
event.respondWith(
fetch("https://css-tricks.com")
);
});
It doesn’t have any error handling or anything, but hey, it works:
Now imagine how …
The...
Responsible JavaScript
2.11.2021
High five to Jeremy on the big release of Responsible JavaScript on A Book Apart. There is a lot of talk about how the proliferation of JavaScript has had a negative impact on the web, but now we have …
The post Responsible JavaScript appeared first on CSS-Tricks. You can support CSS-Tricks...
In-Page Filtered Search With Vanilla JavaScript
26.10.2021
If you have a page that includes a lot of information, it’s a good idea to let users search for what they might be looking for. I’m not talking about searching a database or even searching JSON data — I’m …
The post In-Page Filtered Search With Vanilla JavaScript appeared first...
Command Line trash
24.10.2021
One of the first commands you learn when experimenting with command line is rm, the utility for deleting files and directories. Deletion is a core computer UI operation but operating systems use a “Trash” paradigm, where files are stored before truly deleted. With the rm utility...
WooCommerce + Google Analytics
12.10.2021
Google Analytics is powerful analytics software. A common way to use it is to just slap the JavaScript snippet on every page template you have and let it collect basic data about unique visitors and pageviews and such. That’s useful, …
The post WooCommerce + Google Analytics appeared...
Jekyll doesn’t do components? Liar!
8.10.2021
I like the pushback from Katie Kodes here. I’ve said in the past that I don’t think server-side languages haven’t quite nailed “building in components” as well as JavaScript has, but hey, this is a good point:
1. Any basic
…
The post Jekyll doesn’t...
Scroll Shadows With JavaScript
6.10.2021
Scroll shadows are when you can see a little inset shadow on elements if (and only if) you can scroll in that direction. It’s just good UX. You can actually pull it off in CSS, which I think is …
The post Scroll Shadows With JavaScript appeared first on CSS-Tricks. You can support...
Links on React and JavaScript II
1.10.2021
How To Use The Vite Build Tool with React — Vite is hot, in part, because it’s based on esbuild and wickedly fast. It’s from Evan You of Vue fame, but it’s not a Vue-specific tool. Here, NARUHODO covers how
…
The post Links on React and JavaScript II appeared first...
How to Create a UUID in JavaScript
30.9.2021
The UUID identifier has been used in programming since the days a baby-faced David Walsh became a professional software engineer. My first exposure to UUIDs was via a ColdFusion app I inherited and … the less we say about that the better. In any event, I was recently surprised to see that...
Comparing Methods for Appending and Inserting With JavaScript
24.9.2021
Let’s say we want to add something to a webpage after the initial load. JavaScript gives us a variety of tools. Perhaps you’ve used some of them, like append, appendChild, insertAdjacentHTML, or innerHTML.
The difficult thing …
The post Comparing Methods for Appending...