Most developers know what Reflow and Repaint are.Very few know when they silently kill performance. Here’s the real breakdown 👇 🔁 Reflow — the expensive one Occurs when the browser recalculates layout, sometimes affecting the entire page, not just one element. Triggered by: • Reading offsetWidth, scrollTop, getBoundingClientRect() inside loops • Adding or removing DOM elements • Changing width, height, font-size • Window resize ⚠️ The silent killer: Layout Thrashing When you alternate DOM reads and writes in the same loop, the browser repeatedly forces layout recalculation, leading to major performance issues. 🎨 Repaint — the cheaper cousin Only redraws pixels while layout stays unchanged. Triggered by: • color • background-color • box-shadow • visibility Repaint is cheaper than reflow — but still not free on complex pages. 🚀 What actually improves performance • Batch DOM reads first, then writes • Use transform & opacity for animations (GPU-composited) • Use will-change: transform for frequently animated elements • Use Chrome DevTools Performance tab — large Layout blocks indicate costly reflows Reflow isn’t always avoidable, but triggering it blindly can hurt performance. The best frontend engineers don’t just write correct code — they write browser-aware code. #Frontend #WebPerformance #JavaScript #BrowserInternals #WebDevelopment #CSS
Reflow vs Repaint: Browser Performance Killers
More Relevant Posts
-
There is a massive difference between knowing how to copy code and knowing how to build from a blank screen. I’ve been pushing my frontend skills recently, and this week I challenged myself to build a Calendar View component using nothing but HTML and Tailwind CSS. Completely from scratch. No shortcuts, no relying on tools to write the logic for me. Honestly? I stared at a blank screen for a bit. I fought with terminal path errors just trying to get the build environment running. I had to really wrap my head around the logic of using CSS Grid to map out the 7-day layout, and then nesting Flexbox inside it just to get the number "25" perfectly centered in a blue circle. But that moment when the grid finally snapped into place and looked exactly like the design? That is a feeling you just cannot get from watching a tutorial. My biggest takeaway for anyone learning web layouts right now: Use Grid to build the "parking lot" (your main structure and rows), and use Flexbox to "park the car" (centering the micro-details inside those boxes). Frontend folks—what was the CSS concept that finally made layouts "click" in your head? #hiteshchoudhary #tailwind #frontend #UMT #WebDevelopment
To view or add a comment, sign in
-
The Bridge Between Code and Design 🌉 It’s an incredible feeling to realize that every part of a website can be changed, styled, or even created out of thin air using code! Here is what I learn today: DOM Traversal: Learning how to "find" elements using getElementById, getElementsByClassName, and the powerful querySelector. Dynamic Styling: Using JS to add/remove CSS classes and change styles on the fly. Content Control: Manipulating innerText vs innerHTML and handling attributes with setAttribute. The DOM Tree: Understanding the relationship between parentNode and childNodes. Dynamic Creation: Building entirely new HTML elements from scratch using createElement and appendChild. Learning the difference between a NodeList and an HTMLCollection was a "lightbulb moment" for me today. It’s all about how we interact with the structure of the web. Now, instead of just designing static pages, I’m learning how to build truly interactive experiences. 🚀 #JavaScript #WebDesign #DOM #FrontEndDev #CodingJourney #WebDevelopment #HTML5 #CSS3
To view or add a comment, sign in
-
Quick tip: CSS scroll-snap Ever scroll through a horizontal gallery and the card stops halfway on the screen? Super annoying. In the past, making elements "snap" into place usually meant adding a heavy JS slider library. Now you can do it with just a couple lines of CSS using scroll-snap. Here’s the idea: you define the snapping behavior on the container, and the alignment point on the items inside it. Container: .scroll-container { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; } Items: .card { scroll-snap-align: start; } Now when you scroll, each card neatly snaps into place at the edge of the container. Where this works great: 1 sliders and image galleries 2 vertical landing pages with section-by-section scrolling 3 calendars or date pickers where the selected value should land in the center Why it’s great: 1 it’s native browser behavior, so it runs smoothly (60 FPS even on older devices) 2 touch gestures feel natural because the browser handles inertia 3 keyboard and mouse scrolling respect the snap points too Pro tip: if you don’t want the snapping to feel too strict, use scroll-snap-type: x proximity. That way snapping only happens when the scroll stops close to the alignment point. #css #webdev #frontend #webdevelopment #codingtips
To view or add a comment, sign in
-
-
#Hello_Connections #Day32 of #100DaysOfCode Built an Advanced Image Slider using Bootstrap 5 Features: Fully responsive carousel Multiple slides with smooth transitions Dark overlay for better text visibility Text + buttons on each slide Indicators and navigation controls This component can be used in landing pages, portfolios, or modern website UI. Continuing to improve my frontend skills step by step Code Of School Avinash Gour & Ritendra Gour #HTML #CSS #Bootstrap #WebDevelopment #Frontend #LearningJourney
To view or add a comment, sign in
-
Frontend looks easy… until it really isn’t 😅 At first, it feels like: “Just some HTML, CSS, and a bit of JavaScript… should be straightforward.” Then you start building 👇 • Pixel-perfect design 🎯 That tiny 2px difference? Yeah… it suddenly matters more than you expected. • Cross-browser issues 🌐 Everything looks perfect on Chrome… Then Safari humbles you real quick. • Mobile responsiveness 📱 A clean desktop layout can turn into a completely different story on smaller screens. • That one CSS bug 🐛 You fix one thing… and somehow three new issues show up. • And then come animations ✨ Modern UIs almost expect them now. But getting them right? • Smooth timing • Natural feel • Good performance That’s where things get interesting (and sometimes frustrating). Frontend isn’t just about making things look good — It’s about creating an experience that feels right across every screen, browser, and interaction. And honestly, that challenge is what makes it worth it 🚀 #frontend #webdevelopment #javascript #animation #uiux #developerlife
To view or add a comment, sign in
-
Most beginners break layouts without realizing it. I was doing the same. Day 20 of rebuilding my Frontend skills with #LearningToMakeLivingOnline from Talha Tariq, GreatFrontEnd. Today I focused on something small… but powerful: 👉 Why layouts break (and how to fix them properly) 🚨 Common mistakes I fixed: • Using width: 100% + padding → causes overflow • Forgetting box-sizing: border-box • Not handling long text (it breaks containers) • Ignoring overflow behavior ✅ Simple fixes that changed everything: * { box-sizing: border-box; } .container { max-width: 1200px; margin: 0 auto; padding: 1rem; overflow: hidden; } p { word-wrap: break-word; } 💡 What I learned: Clean layouts are not about making things look right, They’re about preventing things from breaking. That’s the difference between: 👉 Writing CSS 👉 And understanding CSS What CSS bug wasted your time the most? #webdevelopment #frontend #css #buildinpublic #developer #learning
To view or add a comment, sign in
-
-
Bringing "Shin-chan's Crazy Adventures" to life with HTML & CSS! 🚀Day-1 I recently challenged myself to build a modern, responsive landing page for one of my favorite childhood shows. This project allowed me to dive deep into custom layouts and UI components. Key Features: • Responsive Navigation: A sleek header with functional hover states. • Hero Section: Integrated a dynamic background with clear Call-to-Action (CTA) buttons. • Card Layouts: Used [CSS Grid/Flexbox] to create a clean "New Movies" gallery. • Character Profiles: A dedicated section using hover effects to introduce "The Gang." Tech Stack: HTML5, CSS3 (Custom properties, Flexbox, and Media Queries). Check out the screen recording below to see the UI in action! I’d love to hear your thoughts on the layout. #WebDevelopment #Frontend #HTML #CSS #Programming #UIUX #Shinchan #CodingProject
To view or add a comment, sign in
-
🤦♀️ 𝐀 𝐒𝐦𝐚𝐥𝐥 𝐂𝐒𝐒 𝐇𝐚𝐜𝐤 𝐂𝐚𝐮𝐬𝐞𝐝 𝐚 𝐁𝐢𝐠 𝐔𝐈 𝐁𝐮𝐠… Yesterday I spent almost 30 minutes debugging something that made no sense. I clicked on a Clock component ⏰ in my React UI and somehow it was changing the website theme 🌙☀️. At first I thought: Maybe the click event is bubbling 🤔 Maybe the Clock component has some hidden handler Maybe React state is behaving weirdly But none of those were the problem. Then I opened Chrome DevTools and inspected the elements. And there it was… 👀 The theme toggle button was invisibly overlapping the clock. Why? Because of negative margins. <𝘐𝘤𝘰𝘯𝘉𝘶𝘵𝘵𝘰𝘯 𝘰𝘯𝘊𝘭𝘪𝘤𝘬={() => 𝘵𝘰𝘨𝘨𝘭𝘦𝘋𝘢𝘳𝘬𝘛𝘩𝘦𝘮𝘦("𝘵𝘩𝘦𝘮𝘦", "")}> <𝘍𝘰𝘯𝘵𝘈𝘸𝘦𝘴𝘰𝘮𝘦𝘐𝘤𝘰𝘯 𝘴𝘵𝘺𝘭𝘦={{ 𝘮𝘢𝘳𝘨𝘪𝘯𝘓𝘦𝘧𝘵: "-130𝘱𝘹" }} /> </𝘐𝘤𝘰𝘯𝘉𝘶𝘵𝘵𝘰𝘯> <𝘥𝘪𝘷 𝘴𝘵𝘺𝘭𝘦={{ 𝘮𝘢𝘳𝘨𝘪𝘯𝘓𝘦𝘧𝘵: "-60𝘱𝘹" }}> <𝘊𝘭𝘰𝘤𝘬 /> </𝘥𝘪𝘷> The button was pushed 130px to the left, extending its clickable area. So whenever I clicked the clock, I was actually clicking the IconButton sitting on top of it. ⚠️ Invisible UI overlaps are one of the trickiest frontend bugs. Instead of using layout hacks, I fixed it using Flexbox: <𝘎𝘳𝘪𝘥 𝘪𝘵𝘦𝘮 𝘴𝘵𝘺𝘭𝘦={{ 𝘥𝘪𝘴𝘱𝘭𝘢𝘺: "𝘧𝘭𝘦𝘹", 𝘢𝘭𝘪𝘨𝘯𝘐𝘵𝘦𝘮𝘴: "𝘤𝘦𝘯𝘵𝘦𝘳", 𝘨𝘢𝘱: "10𝘱𝘹" }}> <𝘐𝘤𝘰𝘯𝘉𝘶𝘵𝘵𝘰𝘯 𝘰𝘯𝘊𝘭𝘪𝘤𝘬={() => 𝘵𝘰𝘨𝘨𝘭𝘦𝘋𝘢𝘳𝘬𝘛𝘩𝘦𝘮𝘦("𝘵𝘩𝘦𝘮𝘦", "")}> <𝘍𝘰𝘯𝘵𝘈𝘸𝘦𝘴𝘰𝘮𝘦𝘐𝘤𝘰𝘯 /> </𝘐𝘤𝘰𝘯𝘉𝘶𝘵𝘵𝘰𝘯> <𝘊𝘭𝘰𝘤𝘬 /> </𝘎𝘳𝘪𝘥> ✔ Removed negative margins ✔ Used display: flex for layout ✔ Added gap for spacing ✔ No more overlapping click areas ✨ Lesson learned: Modern CSS (Flexbox/Grid) is far more reliable than using negative margins for layout. Sometimes the bug isn’t in your JavaScript logic… It’s hiding in your CSS layout. Have you ever faced a bug where the UI looked correct but behaved completely wrong? #FrontendDevelopment #ReactJS #CSS #Debugging #WebDevelopment #Programming
To view or add a comment, sign in
-
🚀 Day 12 of My Full Stack Development Journey Today I learned one of the most important concepts in CSS — the Box Model 📦 Here’s what I explored today: 🔹 Box Model – Understanding content, padding, border, and margin 🔹 Height & Width – Controlling the size of elements 🔹 Border & Border Radius – Styling element borders and creating rounded corners 🔹 Padding – Space inside the element 🔹 Margin – Space outside the element This concept really helped me understand how layout and spacing work in web design. Now I can better control how elements are placed and spaced on a webpage 🎯 Learning step by step and improving every day 💻✨ #FullStackJourney #WebDevelopment #CSS #LearningInPublic #100DaysOfCode
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