⚠️ Your UI isn't slow… your Call Stack is blocked. Ever clicked a button on a website and nothing happens for a few seconds? Scrolling freezes. Animations stop. Inputs lag. Most developers start optimizing components or blaming network delays. But the real problem is simple: 🧠 JavaScript has only ONE call stack. If a heavy task runs on it: for (let i = 0; i < 10000000000; i++) {} Your entire UI is blocked. No clicks. No rendering. No updates. 💡 The fix → Web Workers Move heavy work to another thread. const worker = new Worker("worker.js"); worker.postMessage(data); Now the computation runs in a separate thread with its own call stack, while your UI stays smooth. ⚡ Main Thread → UI ⚡ Worker Thread → Heavy computation Small concept. Massive performance impact. #JavaScript #FrontendEngineering #WebWorkers #BrowserInternals
JavaScript Call Stack Blocking UI Performance Issues
More Relevant Posts
-
⚡ 𝗥𝗲𝗮𝗰𝘁 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝗖𝗼𝗺𝗽𝗮𝗿𝗶𝘀𝗼𝗻: 𝒖𝒔𝒆𝑻𝒓𝒂𝒏𝒔𝒊𝒕𝒊𝒐𝒏 𝘃𝘀 𝒖𝒔𝒆𝑫𝒆𝒇𝒆𝒓𝒓𝒆𝒅𝑽𝒂𝒍𝒖𝒆 Modern React gives us powerful primitives to keep UIs responsive, but many engineers still struggle to choose between 𝒖𝒔𝒆𝑻𝒓𝒂𝒏𝒔𝒊𝒕𝒊𝒐𝒏 and 𝒖𝒔𝒆𝑫𝒆𝒇𝒆𝒓𝒓𝒆𝒅𝑽𝒂𝒍𝒖𝒆. They both help avoid blocking renders. But they solve different architectural problems. Let's clarify 👇 🔎 𝒖𝒔𝒆𝑻𝒓𝒂𝒏𝒔𝒊𝒕𝒊𝒐𝒏 → Defer a state update Use it when you control the update and want to mark it as low-priority. 𝑐𝑜𝑛𝑠𝑡 [𝑖𝑠𝑃𝑒𝑛𝑑𝑖𝑛𝑔, 𝑠𝑡𝑎𝑟𝑡𝑇𝑟𝑎𝑛𝑠𝑖𝑡𝑖𝑜𝑛] = 𝑢𝑠𝑒𝑇𝑟𝑎𝑛𝑠𝑖𝑡𝑖𝑜𝑛(); 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 ℎ𝑎𝑛𝑑𝑙𝑒𝐶ℎ𝑎𝑛𝑔𝑒(𝑣𝑎𝑙𝑢𝑒) { 𝑠𝑒𝑡𝐼𝑛𝑝𝑢𝑡(𝑣𝑎𝑙𝑢𝑒); // 𝑢𝑟𝑔𝑒𝑛𝑡 𝑢𝑝𝑑𝑎𝑡𝑒 𝑠𝑡𝑎𝑟𝑡𝑇𝑟𝑎𝑛𝑠𝑖𝑡𝑖𝑜𝑛(() => { 𝑠𝑒𝑡𝐹𝑖𝑙𝑡𝑒𝑟𝑒𝑑𝐿𝑖𝑠𝑡(𝑒𝑥𝑝𝑒𝑛𝑠𝑖𝑣𝑒𝐶𝑜𝑚𝑝𝑢𝑡𝑒(𝑣𝑎𝑙𝑢𝑒)); // 𝑑𝑒𝑓𝑒𝑟𝑟𝑒𝑑 𝑢𝑝𝑑𝑎𝑡𝑒 }); } Key idea: You decide which state updates are urgent vs non-urgent. Best use cases: • Filtering large lists • Navigation / route transitions • Expensive UI recomputation • Background state updates 🧠 𝒖𝒔𝒆𝑫𝒆𝒇𝒆𝒓𝒓𝒆𝒅𝑽𝒂𝒍𝒖𝒆 → Defer a value Use it when you don’t control where the expensive render happens, typically in a child component. 𝑐𝑜𝑛𝑠𝑡 𝑑𝑒𝑓𝑒𝑟𝑟𝑒𝑑𝑄𝑢𝑒𝑟𝑦 = 𝑢𝑠𝑒𝐷𝑒𝑓𝑒𝑟𝑟𝑒𝑑𝑉𝑎𝑙𝑢𝑒(𝑞𝑢𝑒𝑟𝑦); <𝑆𝑒𝑎𝑟𝑐ℎ𝑅𝑒𝑠𝑢𝑙𝑡𝑠 𝑞𝑢𝑒𝑟𝑦={𝑑𝑒𝑓𝑒𝑟𝑟𝑒𝑑𝑄𝑢𝑒𝑟𝑦} /> Key idea: React lets part of the UI "lag behind" automatically while keeping interactions responsive. Best use cases: • Search-as-you-type • Large charts or tables • Expensive child components • Preventing typing lag 🎯 How to Think About It • 𝒖𝒔𝒆𝑻𝒓𝒂𝒏𝒔𝒊𝒕𝒊𝒐𝒏 → defer the update • 𝒖𝒔𝒆𝑫𝒆𝒇𝒆𝒓𝒓𝒆𝒅𝑽𝒂𝒍𝒖𝒆 → defer the rendering impact of a value Both rely on concurrent rendering: React schedules background work and can interrupt it if new interactions occur. 🚀 Takeaway: These hooks are not micro-optimizations. They are scheduling primitives that help design responsive architectures at scale. Used correctly, they improve perceived performance without hacks like artificial delays or heavy memoization. How are you applying concurrent rendering patterns in real production UIs? #React #WebPerformance #FrontendArchitecture #JavaScript
To view or add a comment, sign in
-
-
Modern web performance challenges are not always rooted in inefficient code, but often in the underlying browser architecture. Cheng Lou has recently explored an alternative approach to UI rendering that questions long-standing assumptions in frontend development. In the current model, every UI update passes through a sequence of steps: • DOM updates • Layout recalculation (reflow) • Paint and compositing This pipeline operates on the main thread and can introduce latency, particularly in complex applications where frequent updates are required. An emerging experimental direction proposes: • Reducing or eliminating dependency on the DOM • Avoiding traditional CSS-based layout systems • Implementing a custom rendering layer using TypeScript • Drawing UI elements directly, similar to canvas or GPU-driven approaches The potential advantages include: • Improved rendering performance • Greater control over layout and updates • More predictable behavior under heavy UI workloads However, this approach also introduces trade-offs: • Increased implementation complexity • Limited ecosystem and tooling support • Challenges related to accessibility and search engine optimization This line of exploration does not replace existing frameworks such as React, but it highlights an important shift in thinking—from optimizing within browser constraints to re-evaluating those constraints altogether. As frontend systems continue to evolve, understanding these foundational trade-offs will be critical in making informed architectural decisions. #Frontend #WebDevelopment #React #JavaScript #WebPerformance #SystemDesign
To view or add a comment, sign in
-
**Next.js 15 Server Components — the end of client-side rendering?** Not quite. But it *does* feel like a major shift in how we build for the web. For years, frontend development leaned heavily on client-side rendering: - ship more JavaScript - fetch data in the browser - hydrate everything - hope performance holds up With **Server Components in Next.js 15**, the default mindset is changing: ✅ Fetch data on the server ✅ Keep sensitive logic off the client ✅ Send less JavaScript to the browser ✅ Improve performance and initial load times That’s a big deal. But let’s be clear: **client-side rendering isn’t dead**. We still need client components for: - interactivity - local state - animations - browser-only APIs - rich UI experiences What’s really happening is this: **We’re getting better boundaries.** Instead of treating the entire app like it needs to run in the browser, we can now choose: - **Server Components** for data-heavy, static, and secure parts - **Client Components** for interactive UX That means better performance *and* cleaner architecture. The real question isn’t **“Is this the end of client-side rendering?”** It’s: **“Why were we rendering so much on the client in the first place?”** Next.js 15 doesn’t kill CSR. It makes it **intentional**. And that’s probably the bigger evolution. #nextjs #react #webdevelopment #javascript #frontend #performance #servercomponents #fullstack #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
-
Is "Pretext" the Future of Web Performance❓ If you've ever built a complex UI with dynamic text, you’ve likely hit the "Performance Wall." One library is currently breaking the internet by offering a way over that wall: Pretext. Created by Cheng Lou (former React core member), Pretext has gained over 16,000 GitHub stars in just 24 hours. Here is why the entire dev community is talking about it. 🔗 Pretext: https://lnkd.in/dtqiu8ZE 🔗 Live demos: https://lnkd.in/dV5ZPPAK ❓ What is Pretext? Pretext is a high-performance text layout engine for the web. Unlike traditional methods that rely on the browser's Document Object Model (DOM) to figure out where text should go, Pretext handles the layout logic itself. ⚠️ The Problem: The "Layout Reflow" Nightmare In a standard web app, if you want to know how wide a piece of text is, you ask the DOM. This triggers a Layout Reflow—one of the most expensive operations a browser can perform. The browser has to stop everything, recalculate dimensions, and reposition every element on the page. This is why virtual lists, masonry layouts, and fluid UIs often feel "laggy" or "choppy" when scrolling or resizing. 🛠️ How Does It Solve This? Pretext takes a radical "DOM-less" approach to measurement: Canvas-Based Measurement: It uses the Canvas API to measure text segments, which is significantly faster than DOM-based queries. One-Time Preparation: It performs the "heavy lifting" (normalizing whitespace and segmenting text) just once. Pure Arithmetic: Once measured, it uses pure mathematical calculations and cached data to handle layouts. It essentially tells the browser where to put text, rather than asking the browser where it thinks the text should go. Are you excited to try Pretext in your next project, or do you think the DOM is still king? Let's discuss below! 👇 #JavaScript #WebDevelopment #FrontendEngineering #Pretext #SoftwareArchitecture #WebPerformance #Coding #TechTrends
To view or add a comment, sign in
-
-
⚛️ 𝗣𝗿𝗲𝘃𝗲𝗻𝘁𝗶𝗻𝗴 𝗨𝗻𝗻𝗲𝗰𝗲𝘀𝘀𝗮𝗿𝘆 𝗥𝗲-𝗿𝗲𝗻𝗱𝗲𝗿𝘀 𝗶𝗻 𝗥𝗲𝗮𝗰𝘁 — 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗮𝗹 𝗨𝘀𝗲 𝗼𝗳 𝗺𝗲𝗺𝗼 & 𝘂𝘀𝗲𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸 In React applications, performance issues often come from repeated re-renders rather than heavy logic. This becomes more noticeable when passing functions as props. 𝗖𝗼𝗺𝗺𝗼𝗻 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 <ChildComponent onClick={() => handleClick(id)} /> A new function is created on every render, causing child components to re-render. 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗮𝗹 𝗙𝗶𝘅 Use useCallback: const handleItemClick = useCallback((id) => { handleClick(id) }, []) Then: <ChildComponent onClick={handleItemClick} /> 𝗖𝗼𝗺𝗯𝗶𝗻𝗲 𝘄𝗶𝘁𝗵 𝗥𝗲𝗮𝗰𝘁.𝗺𝗲𝗺𝗼 export default React.memo(ChildComponent) Now child re-renders only when props actually change. 𝗪𝗵𝗲𝗻 𝗧𝗵𝗶𝘀 𝗛𝗲𝗹𝗽𝘀 𝗠𝗼𝘀𝘁 • Large lists • Dashboard UI • Reusable components • Expensive child rendering • Deep component trees 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗮𝗹 𝗡𝗼𝘁𝗲 Avoid over-optimizing: • Use memo only where needed • Measure before optimizing • Keep code readable Small memoization changes can improve UI responsiveness significantly. 💬 Curious — Do you use memoization by default, or only after noticing performance issues? #ReactJS #Frontend #Performance #JavaScript #WebDevelopment #SoftwareEngineering #DevCommunity
To view or add a comment, sign in
-
Are unnecessary re-renders slowing down your React application? We all know the frustration of a laggy UI, but often the solution is hidden within simple optimization techniques we are already using just not effectively. I’ve put together a visualization that simplifies three of the most powerful strategies for optimizing React performance. Here is the quick breakdown: 1. Code Splitting: How React.lazy and Suspense can drastically improve initial load times by loading code only when it's absolutely necessary. 2. The Re-render Problem: Understanding that non-primitive data types (objects/functions) are assigned new memory addresses on every render the main culprit of expensive recalculations. 3. The Memoization Toolkit: A side-by-side comparison of when to deploy React.memo, useCallback, and useMemo to cache components, functions, and heavy calculation values. A little optimization can go a long way toward a smoother user experience. Save this guide for your next optimization sprint! 👇 How do you approach performance tuning in your React projects? Are you using useMemo sparingly, or is it your go-to optimization tool? Let’s share some best practices below. #ReactJS #WebDevelopment #FrontendEngineering #PerformanceOptimization #JavaScript #SoftwareEngineering
To view or add a comment, sign in
-
-
🔖 Built a Simple & Efficient Todo Application I recently developed a Todo Application that helps users manage daily tasks effectively with a clean and user-friendly interface. ✨ Key Features: • Add, update, and delete tasks • Mark tasks as completed • Persistent data storage using local storage • Responsive design for mobile and desktop • Minimal and intuitive UI 🛠️ Tech Stack: HTML | CSS | JavaScript 💡 What I Learned: This project helped me strengthen my understanding of DOM manipulation, event handling, and building interactive web applications. I also focused on writing clean, maintainable code and improving user experience. 📌 Future Improvements: • Add authentication system • Cloud-based storage • Task categories and deadlines Feel free to check it out and share your feedback! #WebDevelopment #JavaScript #Frontend #Projects #Learning #Coding
To view or add a comment, sign in
-
I tried building a UI library using Web Components… and it kept failing. Not once. Not twice. Repeatedly. At first, I thought the problem was the tools. Vite configs breaking. Components not registering. Styles not applying. Things just… not working. But the real issue was simpler—and harder to admit: I didn’t understand what was happening under the hood. I was stacking complexity too early. Custom CLI. Auto-generated files. Build optimizations. Tree-shaking. All of it sounded “professional”… but it turned my project into a black box. When something broke, I had no idea where to even start. So I did something most people avoid: I stripped everything down. No CLI. No abstractions. No fancy setup. Just one Web Component. Built it. Broke it. Fixed it. Repeated. And that’s when things finally started to click. I began to understand: 1. How the Shadow DOM actually works (not just in theory) 2. Why styling feels restrictive—and how to work around it 3. How components communicate using custom events 4. Where integration with frameworks like React can go wrong The result? Not just a working component—but a clear mental model. And that’s the real “streamlined product” most people don’t talk about. It’s not the library. It’s the clarity. Now, rebuilding the system feels different. Simpler. Intentional. Controlled. Lesson learned: If you can’t explain your system, you shouldn’t be scaling it. Start small. Understand deeply. Then build up. #WebComponents #FrontendDevelopment #BuildInPublic #JavaScript #SoftwareEngineering
To view or add a comment, sign in
-
🚨 Ever wondered why JavaScript feels like a coffee menu? JavaScript as a Coffee Order Picture walking into a café. The barista asks what you want. You say I’d like a latte, please ☕. The barista takes that request, processes it, and returns a latte. In JavaScript, you give the browser a request, the engine processes it, and then the browser gives you the result. In a recent post titled Master HTML, CSS, JavaScript in 3 Phases, I broke down the learning path into bite size steps. This coffee analogy shows how each line of code is a small order that the browser turns into something you see. You write const coffee equals latte, then you ask the console to show that variable. The console prints Your drink is latte. Did this help? Save it for later. ✅ Check if your website is ordering the right code. #WebDevelopment #LearnToCode #WordPress #CodingTips #TechEducation #WebDesign #Frontend #HTML #CSS #JavaScript #React #API #ResponsiveDesign #UX #BusinessTech
To view or add a comment, sign in
-
🚀 I just published a new React package: 𝗿𝗲𝗮𝗰𝘁-𝘁𝗵𝗲𝗺𝗶𝗻𝗴-𝗲𝗻𝗴𝗶𝗻𝗲 But honestly — this started from a frustrating problem. While building UI systems, I kept hitting the same roadblocks: ❌ Hardcoded colors everywhere ❌ Dark mode breaking semantic meaning ❌ Runtime theme switching causing performance issues ❌ Tailwind + dynamic theming not playing well together ❌ No clean way to separate “brand colors” from “UI intent” At one point, even a simple “change primary color” feature started affecting multiple components unpredictably. That’s when I realized: the problem wasn’t just theming… it was the lack of a proper architecture. So, I built 𝗿𝗲𝗮𝗰𝘁-𝘁𝗵𝗲𝗺𝗶𝗻𝗴-𝗲𝗻𝗴𝗶𝗻𝗲 around a simple, unbreakable idea: 👉𝘉𝘳𝘢𝘯𝘥 𝘗𝘢𝘭𝘦𝘵𝘵𝘦 → 𝘚𝘦𝘮𝘢𝘯𝘵𝘪𝘤 𝘛𝘰𝘬𝘦𝘯𝘴 → 𝘊𝘚𝘚 𝘝𝘢𝘳𝘪𝘢𝘣𝘭𝘦𝘴 Once I introduced this 3-layer architecture, everything clicked: ✔ Components stopped depending on raw colors ✔ Dark mode became predictable ✔ Runtime overrides (dynamic branding) became safe ✔ Performance stayed solid (zero-runtime via CSS variables) ✔ Works seamlessly with Vanilla CSS, CSS-in-JS, or Tailwind CSS ✨ What it offers: • Clean 3-layer theming architecture • Native Light/Dark mode support • Flexible integration (Tailwind preset included) • Fully type-safe API 🔗 𝗧𝗿𝘆 𝘁𝗵𝗲 𝗶𝗻𝘁𝗲𝗿𝗮𝗰𝘁𝗶𝘃𝗲 𝗽𝗹𝗮𝘆𝗴𝗿𝗼𝘂𝗻𝗱: https://lnkd.in/gN3npmYG 📦 𝗖𝗵𝗲𝗰𝗸 𝗶𝘁 𝗼𝗻 𝗻𝗽𝗺: https://lnkd.in/gU7wiepk 𝗜𝗻𝘀𝘁𝗮𝗹𝗹: npm install react-theming-engine This is still early — would really appreciate feedback from devs building design systems 🙌 Let’s learn and build together! 🚀 #React #ReactJS #TypeScript #Frontend #WebDevelopment #DesignSystems #UIEngineering #ComponentLibrary #CSSVariables #TailwindCSS #OpenSource #DevTools #BuildInPublic #Frontend #SoftwareEngineering #UXEngineering
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development