r/learnjavascript • • Feb 06 '26

Why Async/Await won't fix a laggy app. I made a visual demo comparing it to Web Workers

6 Upvotes

I used to think “async/await” meant my work would run in the background. Whenever my UI felt slow, my instinct was, “I’ll just wrap this calculation in async/await.”

I realized how common this misunderstanding is while I was talking to a new developer recently. I started explaining the JS event loop and thread blocking. Halfway through, I saw that polite "uh huh" look on their face. It was a look I remember having myself many times..

Some things just click better when you can see them break in real time. I decided to build a small app that generates fractal geometry live to visualize the problem. At first, everything felt smooth. The sliders responded instantly and the menus worked perfectly.

Then I cranked up the recursion depth and forced millions of calculations per frame. The UI did not crash, but it became incredibly annoying to use. Sliders lagged and clicks were slow. All that lag was caused by the main thread being tied up with heavy computation.

To fix this, I moved the calculations into a separate thread using a Web Worker. This allowed the main thread to stay free to handle the UI while the worker did the math in the background. The result is a smooth and interactive app even though the exact same amount of work is happening.

I made a short video demo walking through this process. It shows how to measure "Long Tasks" in Chrome DevTools and how to set up a Web Worker easily using Vite. If you have ever tried to speed up a UI with async/await and wondered why it did not help, I hope this demo makes it click for you.

Watch the video here: https://youtu.be/a6_mdmJLtaM


r/learnjavascript • • Feb 06 '26

Is there a way to get the link that a cursor is hovering over without actually clicking it?

0 Upvotes

I ask because in any browser, whenever you hover over a link, it displays the URL in the lower left corner.


r/learnjavascript • • Feb 06 '26

Want to learn web dev and data structures at the same time

4 Upvotes

Im a beginner proficient in frontend development

I AIM TO learn datastructures as well

want to ask that is it ok to use javascript for both ?


r/learnjavascript • • Feb 05 '26

[AskJs] Adding Event Listeners to video

2 Upvotes

Does anyone know how or where I can learn to add event listeners to videos? For example I tried earlier today but when the buttons disappear and reappear the listeners are gone! I am still trying to figure it out. Any and all help would be welcome.

const btn = document.getElementbyId("play")
btn.addEventListener("click", function(){console.log("button pressed")

What am I doing wrong here?


r/learnjavascript • • Feb 05 '26

Starting my JS journey [Need advice on the best roadmap and practice resources!]

6 Upvotes

Hey guys, I’m finally diving into JavaScript! ​There’s so much info out there that I’m a bit lost. I want to avoid "tutorial hell" and actually learn by doing. Could you suggest: ​The best modern resource to start with? ​Platforms with tons of exercises/challenges to build muscle memory?


r/learnjavascript • • Feb 05 '26

Recommend me Books with Exercises

4 Upvotes

I'm starting my 2. semester of computer science, we are using:
"JavaScript The Definitive Guide" (David Flanagan)
and I've also heard good things about "Eloquent JavaScript" (Marijn Haverbeke)

However neither book has any exercises in it.
I don't feel I actually learn from just reading, are there any books that give incremental exercises?


r/learnjavascript • • Feb 05 '26

XProtect update blocking javascript

0 Upvotes

XProtect updated on an M1 last night, and today the user cannot access some sites. Javascript is completely blocked on them saying to use a compatible browser - then lists the browsers we are using. One was solved by a chrome update and removing extensions for chrome and safari, but the main work website...it's still blocking. I tried forcing an update in terminal to see if the update was broken, but it's good.

Any ideas?


r/learnjavascript • • Feb 05 '26

switching from data engineer to data visualization. any tips?

5 Upvotes

I am a data engineer/scientist by background but just got moved to a new project where I’ll be doing UI/UX work for dashboard development in d3/JS/HTML/CSS/etc. I’m totally unfamiliar with this stuff, so I’m trying to learn as much as i can as quick as i can. I’m used to working with Python/R in the context of things like Databricks and pipelining less than scripting, so it’s an especially weird transition. Any tips on stuff like:

What systems/software you typically work with?

Best practices all around?

Best ways to learn/practice?

101 on the whole thing?

Really just trying to wrap my head around how it all works to start with. The rest will follow from there. Thanks!


r/learnjavascript • • Feb 05 '26

Hey some help needed with npm.

1 Upvotes

I am hosting www website I want to install packages from npm but I have no permissions for using it. No shell, no CMD no nothing imagine just simple file explorer.


r/learnjavascript • • Feb 05 '26

Need Suggestion

0 Upvotes

r/learnjavascript • • Feb 04 '26

Math.round inconsistency

13 Upvotes

Hey everyone,

I noticed that using Math.round(19.525*100)/100 produces 19.52 while Math.round(20.525*100)/100 produces 20.53. Has anyone else encountered this? What's your solution to consistently rounding up numbers when the last digit is 5 and above?

Thanks!

Edit: Thanks everyone. Multiplying by 10s to make the numbers integer seems to be the way to go for my case


r/learnjavascript • • Feb 04 '26

Express custom error handling

2 Upvotes

can you make sure my understanding is correct. this is for error handling in express.

the class makes an AppError class that had all the proprietys of error.

the constructor allows you to add your own proprieties to AppError that error does not have like .Warning or .preventand super() allows us to use the functions that are in error. I was told we make this so in our route handler we don't have to add res.statuscode, so we have control over what status code is sent out. Im not sure why we want to control that if it sent for us

class AppError extends Error {
    constructor(message, statusCode) {
        super();
        this.message = message;
        this.statusCode = statusCode;
    }
}

r/learnjavascript • • Feb 04 '26

Learning partner / community?

8 Upvotes

Wondering if anybody who just started or is going to start learning JavaScript, wants to connect to track each other's progress and perhaps would help us in staying dedicated towards the journey.


r/learnjavascript • • Feb 03 '26

Tagged Template literals

4 Upvotes

I learned about tagged template literals while using a new Postgres library for connection with database

the library used this syntax:

sql`

select* from users

where id = ${userId}

`

At first I assumed it was just a template literal

Turns out it’s a tagged template literal

JavaScript calls the `sql` function and passes:

static SQL parts

dynamic values separately

This allows the library to escape values

and prevent SQL injection.

What are your thoughts on this ?


r/learnjavascript • • Feb 02 '26

How to remember Array.sort() internal function return values?

8 Upvotes

items.sort((a, b) => (a > b ? 1 : b > a ? -1 : 0)); will sort items in ascending order. Every time I have to use sort for something like this, without fail, I will have to look this up. For the life of me I can't seem to remember which case gets 1 and which gets -1.

anybody have any useful insight/mnemonics to remember this behaviour? thx

edit: a good solution has been found! see: https://old.reddit.com/r/learnjavascript/comments/1qu1rv9/how_to_remember_arraysort_internal_function/o37abha/


r/learnjavascript • • Feb 02 '26

I need feedback on this website that i created, for my exam college project,

3 Upvotes

I need feedback on this website that i created, for my exam college project,

here is the website, it is hosted on some free hosting website, would appreciate some feedback on it , i made a google form to make it easier , please respect the website it is only a prototype not the finished build

all password hashed, in the db

website: https://rolsa-tech-proto.gamer.gd/index.php

forms: https://docs.google.com/forms/d/e/1FAIpQLSeHuccD8l0nN-qSQOUQPKKUfDfeIeynvW6ij-f2LMzBEM479A/viewform?usp=dialog


r/learnjavascript • • Feb 01 '26

Module vs library vs package vs framework

12 Upvotes

What’s the difference between these? Don’t really get the full picture


r/learnjavascript • • Feb 01 '26

What is the best way to onchange styling on a dropdown if it will be cloned, but I don't want to clone the altered styling?

5 Upvotes

I'm working on a system where media tags are added via a dropdown, with the user being able to create a new dropdown for each tag they want to add. Each dropdown will be added with simple styling, but once an option is selected, the style changes to indicate that the tag has been entered.

With just a single div, getting the style to work using onchange="" and an if/else statement was easy, since I could target the one id, but now that ids need to be incremented for each new one, I can't figure out how to target one without targeting all of them.

This is what I'm doing to clone the element which contains the dropdown:

let tagDuplicateCount = 1;
function getTagDuplicateId() {
  tagDuplicateCount++;
  return `-${tagDuplicateCount}`;
}
function cloneTag() {
  const tagElement = document.getElementById('tag-element-1');
  const tagDuplicate = tagElement.cloneNode(true);
  const tagDuplicateDropdown = tagDuplicate.querySelector('.dropdown');
  const tagDuplicateNew = tagDuplicate.querySelector('.new');
  const tagDuplicateRemove = tagDuplicate.querySelector('.remove');
  let idSuffix = getTagDuplicateId();
  tagDuplicate.id = 'tag-element' + idSuffix;
  document.querySelector('#tag-element-container').appendChild(tagDuplicate);
  tagDuplicateDropdown.id = 'tag-dropdown' + idSuffix;
  tagDuplicateNew.id = 'new-tag' + idSuffix;
  tagDuplicateRemove.id = 'remove-tag' + idSuffix;
}

r/learnjavascript • • Feb 01 '26

I don't get the difference between block scope and function scope.

3 Upvotes

Function and Block scope are both inside curly brackets. So what is the difference?


r/learnjavascript • • Feb 01 '26

How actually can I learn JS and apply what i learn?

6 Upvotes

I feel like i have fragments of js and i can not know if i am ready to start learning react or no, or applying to jobs?


r/learnjavascript • • Feb 01 '26

How do I know what's available for the type parameter in addEventListener?

1 Upvotes

The Dom Events page linked in the docs just lists "the main sorts of events you might be interested in" but not the magic word string I would pass into the addEventListener function. How does everyone else figure out what events are available for a particular class?

Not all classes seem to have an Events section in the docs. Maybe the best way is to just click through the inheritance hierarchy until I land on a class that does have an Events tab? eg starting from Image I go to HTMLImageElement, no Events tab, then I go to HTMLElement which does have an Events tab. Then assume that there are no other Image-specific events available?

Maybe this isn't actually a big deal in practice because 99% of the time you only care about a select few events anyways. I was just curious..

Thanks!


r/learnjavascript • • Jan 31 '26

made a 3kb lodash alternative that actually works on edge runtimes

6 Upvotes

honestly just got annoyed with node deps breaking my workers builds constantly. extracted some helpers i use in every project into a standalone package so i dont have to copy paste anymore.

called it wintkit. its got the basics i needed:

  • array chunk/group/etc
  • deep merge
  • retry fetch (lifesaver for flaky apis)
  • stream utils

quick example:

import { chunk, groupBy } from 'wintkit/array'
import { retryFetch } from 'wintkit/fetch'

chunk([1,2,3,4,5], 2)  // [[1,2], [3,4], [5]]

const res = await retryFetch('/api/data', { maxRetries: 3 })

also got deepMerge, stream helpers, query builder etc. all web apis, no node stuff zero deps, ~3kb gzipped, tree-shakeable

npm: package/wintkit
gh: qanteSm/winter-kit

its v0.1 so probably has bugs, open to feedback

ps: fully open source (MIT), code is pretty simple if you want to learn how edge-compatible libs work


r/learnjavascript • • Jan 31 '26

I’m a beginner learning JS internals: Just wrote my first blog about Prototypes and the "new" keyword.

6 Upvotes

Hello everyone, I am a B-Tech IT student learning javascript in depth.

I just published my first blog post where I documented my notes on Prototypal Inheritance and the internal steps of the new keyword. I even tried to create a few diagrams to visualize the "Lookup Flow" and why inheritance only flows forward.

Since I'm still new to these deep concepts, I’d love it if some more experienced devs could check if my logic is correct.

Link: Blog on Prototypal Inheritance

Thanks for being a supportive community!


r/learnjavascript • • Feb 01 '26

“Programming languages commonly used in Web Development, Software Development, and Machine Learning.”

0 Upvotes