Stop letting forced synchronous reflow kill your app's performance. 🚀 If you’ve ever built a virtualized list or a complex chat interface, you’ve likely hit the "DOM measurement trap." Every time you call getBoundingClientRect(), offsetHeight, or scrollHeight, the browser must pause, flush style changes, and perform a full rendering pass just to tell you a box's size. In a list of 500+ items, this "thrashing" can easily cost 30ms+ per frame, murdering your 60fps dreams. Enter Pretext.js, a new library from Cheng Lou (formerly of the React core team) that measures and positions multiline text entirely through pure arithmetic—without ever touching the DOM. Why this is a game-changer for developers: 🎨 Beyond the DOM: It opens the door for accurate text layout in Canvas and WebGL (think Figma or Miro) and future Server-Side Rendering. ♿ Accessibility: While it bypasses the DOM for measurement, you can still build fully accessible demos with semantic HTML, keyboard operability, and screen reader support. Check out this video for more https://lnkd.in/gvwnV68k #WebDev #JavaScript #TypeScript #Frontend #Performance #PretextJS #React #CodingTips
Pretext.js: Avoid DOM Measurement Trap for Better App Performance
More Relevant Posts
-
this is actually crazy 🤯 Cheng Lou (ex React) just dropped Pretext and it blew up instantly — demos, github, everyone testing it the main thing: you don’t need to render text to understand it anymore you just know: how many lines how it wraps how much space it takes before anything loads and people are already doing cool stuff with it: • chat bubbles that fit perfectly (no weird empty space) • long feeds that don’t jump when loading • canvas apps with accurate text (like figma / miro) • UI that adapts to content without breaking there’s even a thing where you can find the exact width for a text to stay in 2–3 lines (css can’t do that) it just removes a lot of annoying frontend problems
To view or add a comment, sign in
-
🔐 Built a Clean & Interactive OTP Input Component using React Recently, I worked on building a fully functional OTP (One-Time Password) input UI with a focus on both user experience and real-world usability. ✨ Key Features: • Auto-focus on next input while typing • Backspace navigation (moves to previous input) • Input validation (only digits allowed) • Clean and responsive UI with modern styling • Ref handling using useRef for DOM control 💡 This is a commonly asked frontend interview question in companies like Microsoft, Google, Atlassian, etc., and a great example of how DSA + DOM manipulation + UX thinking come together in real-world applications. 🧠 What I learned: Managing focus dynamically, handling edge cases (like backspace & paste), and building a smooth user experience using React hooks. 🚀 Live demo & code: 👉 GitHub: https://lnkd.in/ga92Jib9 Would love to hear your feedback and suggestions! #ReactJS #FrontendDevelopment #JavaScript #WebDevelopment #UIUX #Coding #InterviewPreparation #100DaysOfCode
To view or add a comment, sign in
-
Are you using RxJS the right way? 🤔 In frontend development, there are 4 key operators for handling async requests: switchMap – mergeMap – concatMap – exhaustMap Let’s break it down with a simple example 👇 Imagine you have a search box 🎬 Every time the user types, you send a request to fetch movies Here’s the difference: 🔁 switchMap Cancels the previous request and only keeps the latest one 👉 Best choice for search ⚡ mergeMap Runs all requests in parallel 👉 Can lead to messy results and performance issues 📋 concatMap Queues requests and runs them one after another 👉 Useful when order matters 🚫 exhaustMap Ignores new requests until the current one is done 👉 Great for preventing spam clicks 💡 Takeaway: Choosing the right operator = better UX + better performance #Angular #RxJS #Frontend #WebDevelopment
To view or add a comment, sign in
-
Ever noticed how some apps feel instant while others feel sluggish? 🐌 The secret isn't just a faster backend—it's the power of Optimistic UI. Instead of waiting for a server response to update the interface, we assume success and update the UI state immediately. If the request fails, we gracefully roll back. This creates a perceived performance boost that users absolutely love. ⚡️ Implementing this in modern frameworks like React or using tools like TanStack Query takes a bit more logic, but the trade-off in user experience is massive. It transforms a frustrating "loading spinner" moment into a seamless, snappy interaction. How are you handling async states in your latest project? Are you still showing a spinner for every action, or are you going optimistic? Let’s discuss below! 👇 #WebDevelopment #ReactJS #UXDesign #Frontend #JavaScript #SoftwareEngineering #TechTips
To view or add a comment, sign in
-
🚀 𝗙𝗶𝘅𝗶𝗻𝗴 𝗥𝗲𝗮𝗰𝘁 𝗧𝗮𝗯𝗹𝗲 𝗟𝗮𝗴 𝗪𝗵𝗲𝗻 𝗨𝘀𝗲𝗿𝘀 𝗦𝗲𝗹𝗲𝗰𝘁 𝗠𝘂𝗹𝘁𝗶𝗽𝗹𝗲 𝗥𝗼𝘄𝘀 Recently worked on a performance issue where the React Table UI started lagging whenever users selected multiple rows. As the number of selected rows increased, the table became slow and less responsive. 🔍 𝗥𝗼𝗼𝘁 𝗖𝗮𝘂𝘀𝗲: Unnecessary re-renders of rows and table components Expensive state updates on every selection change Repeated calculations during row selection 💡 𝗦𝗼𝗹𝘂𝘁𝗶𝗼𝗻 𝗜𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁𝗲𝗱: Optimized state management for row selection Used useMemo and useCallback to prevent redundant renders Applied component memoization for better rendering control Ensured only affected rows updated instead of the full table refresh ✅ 𝗥𝗲𝘀𝘂𝗹𝘁: Smooth multi-row selection Faster UI response time Better scalability for large datasets Improved overall user experience 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝗼𝗽𝘁𝗶𝗺𝗶𝘇𝗮𝘁𝗶𝗼𝗻 𝗶𝘀 𝗻𝗼𝘁 𝗷𝘂𝘀𝘁 𝗮𝗯𝗼𝘂𝘁 𝘀𝗽𝗲𝗲𝗱 — 𝗶𝘁’𝘀 𝗮𝗯𝗼𝘂𝘁 𝗰𝗿𝗲𝗮𝘁𝗶𝗻𝗴 𝗮 𝘀𝗲𝗮𝗺𝗹𝗲𝘀𝘀 𝗲𝘅𝗽𝗲𝗿𝗶𝗲𝗻𝗰𝗲 𝗳𝗼𝗿 𝘂𝘀𝗲𝗿𝘀. ⚡ #ReactJS #FrontendDevelopment #PerformanceOptimization #JavaScript #WebDevelopment #ReactTable #UIUX #CodingJourney
To view or add a comment, sign in
-
"WebAssembly is the secret weapon for compute-heavy web apps that 90% of developers haven't fully tapped into." Have you ever hit a performance ceiling when building complex web applications? For years, I've battled the constraints of JavaScript when handling intensive calculations. Then, WebAssembly came into my toolkit, and it felt like unlocking a new level in the game of web development. Why should you care about WebAssembly? It lets you run code at near-native speed in the browser, which means quicker load times and a smoother user experience—especially crucial for data-intensive applications like image processing, 3D rendering, and complex simulations. Consider a real-world scenario: implementing a video editor in the browser. The traditional JavaScript approach left users waiting and watching the loading spinner. When I switched to WebAssembly for processing tasks, the difference was staggering. Tasks that once took seconds now happen in milliseconds. It's like comparing a bicycle to a hypercar. Here's a small example in TypeScript showing how easy it is to start using WebAssembly: ```typescript const wasmCode = new Uint8Array
To view or add a comment, sign in
-
Understanding React at a deeper level isn’t about knowing more hooks — it’s about knowing when to use them correctly. useEffect and useLayoutEffect may look similar, but their timing can directly impact performance and user experience. 🔹 useEffect Runs after the component renders and the browser paints the UI. It’s non-blocking and ideal for side effects like API calls, subscriptions, event listeners, and async operations. 🔹 useLayoutEffect Runs synchronously after DOM updates but before the browser paints. It blocks rendering, making it useful for DOM measurements, layout adjustments, and preventing visual flickers. Mastering these small details is what separates clean code from truly optimized applications. #React #ReactNative #FrontendDevelopment #JavaScript #SoftwareEngineering #WebDevelopment
To view or add a comment, sign in
-
-
The New Architecture (Fabric + TurboModules) is no longer optional — it’s becoming the standard. For years, React Native apps relied on the old bridge system. But now, things are changing FAST 👇 With Fabric + TurboModules, hooks-based APIs are increasing: Example from the latest libraries: useSecureStorage useSecret useSecureOperation 👉 New libraries are shifting to hook-first APIs for native features. ⚙️ What’s new? • Fabric → Faster UI rendering & smoother interactions • TurboModules → Efficient native module loading • Less bridge communication → Better performance ⚡ #ReactNative #MobileDevelopment #JavaScript #SoftwareEngineering #AppDevelopment #TechTrends #Developers
To view or add a comment, sign in
-
-
Whether you're building a complex dashboard or a simple search bar, UI jank is the ultimate vibe-killer. If you've ever felt like your app was "stuttering" because a heavy UI update was fighting with user input, useDeferredValue is about to become your new best friend. Here’s the breakdown of why this hook is a game-changer for React performance. 🚀 💡 The Problem: Blocking the Main Thread Normally, React updates are urgent. If a user types into an input and that input triggers a massive re-render (like filtering a list of 10,000 items), the typing feels "laggy" because React is too busy rendering the list to handle the keystrokes. ✨ The Solution: useDeferredValue This hook allows you to mark a piece of state as non-urgent. It tells React: "Hey, keep the input feeling snappy. Update the heavy UI when you have a spare moment." 🛠️ How it works: 1. React updates the "urgent" state (the input text) immediately. 2. It then attempts to render the "deferred" value in the background. 3. If the user types again before the background render finishes, React interrupts the old render and starts over with the new value. ⚡ When to use it? Expensive Re-renders: When a part of your UI is slow to render and there's no way to further optimize the component itself. Search/Filtering: Keeping the search input responsive while the results list "catches up." Third-party integrations: When you're passing data to a library that you don't have performance control over. Pro-Tip: For the best UX, pair it with React.memo on the component receiving the deferred value. This ensures the component only re-renders when the deferred value actually changes! Have you made the switch from traditional debouncing to useDeferredValue yet? Let’s talk about it in the comments! 👇 #ReactJS #WebDevelopment #Frontend #JavaScript #CodingTips #React18 #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 𝗕𝗼𝗼𝘀𝘁 𝗬𝗼𝘂𝗿 𝗥𝗲𝗮𝗰𝘁 𝗔𝗽𝗽 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝘄𝗶𝘁𝗵 𝗩𝗶𝗿𝘁𝘂𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻! Ever tried rendering 1000s of items in React and noticed your app slowing down? 😓 That’s where 𝗩𝗶𝗿𝘁𝘂𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻 (𝗪𝗶𝗻𝗱𝗼𝘄𝗶𝗻𝗴) comes to the rescue! 💡 𝗪𝗵𝗮𝘁 𝗶𝘀 𝗩𝗶𝗿𝘁𝘂𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻? Virtualization is a technique where React renders only the visible items on the screen, instead of the entire list. 👉 Instead of loading 10,000 items at once, it loads just what the user can see 👀 ⚡ 𝗪𝗵𝘆 𝘀𝗵𝗼𝘂𝗹𝗱 𝘆𝗼𝘂 𝗰𝗮𝗿𝗲? ✔ Faster rendering ✔ Smooth scrolling ✔ Reduced memory usage ✔ Better user experience 🧠 𝗛𝗼𝘄 𝗶𝘁 𝘄𝗼𝗿𝗸𝘀 (𝘀𝗶𝗺𝗽𝗹𝗲 𝗶𝗱𝗲𝗮): • Render only visible items • Remove items that go off-screen • Add new items as user scrolls 📦 𝗣𝗼𝗽𝘂𝗹𝗮𝗿 𝗟𝗶𝗯𝗿𝗮𝗿𝗶𝗲𝘀: 🔹 react-window (lightweight & fast) 🔹 react-virtualized (feature-rich) 📊 𝗪𝗶𝘁𝗵𝗼𝘂𝘁 𝘃𝘀 𝗪𝗶𝘁𝗵 𝗩𝗶𝗿𝘁𝘂𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻 ❌ Rendering all items → Slow, heavy UI ✅ Rendering visible items → Fast, smooth UI 📌 𝗪𝗵𝗲𝗻 𝘁𝗼 𝘂𝘀𝗲 𝗶𝘁? 👉 Large datasets (1000+ items) 👉 Tables, feeds, chat apps 👉 Infinite scrolling UI ⚠️ 𝗞𝗲𝗲𝗽 𝗶𝗻 𝗺𝗶𝗻𝗱: • Dynamic heights can be tricky • Needs careful scroll handling • Not needed for small lists 💬 𝗣𝗿𝗼 𝗧𝗶𝗽: If your React app feels slow while scrolling… 👉 Virtualization might be the missing piece! 🔥 Start building high-performance React apps today! #ReactJS #WebDevelopment #Frontend #JavaScript #Performance #SoftwareEngineering
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