Sync notification count across browser tabs in JavaScript Problem: User opened two tabs. Marked notifications as read in one tab but the other tab still showed the unread badge. To sync across tabs, there are two approaches. 1. Using storage event: When one tab updates localStorage, other tabs receive an event. Pros: - Works almost everywhere - Very simple Cons: - Only works with string-based storage - Doesn’t fire in same tab 2. Using BroadcastChannel Pros: - Designed for cross-tab communication - Works for any message payload Cons: - Needs fallback for older browsers For modern apps, BroadcastChannel feels much cleaner. For maximum compatibility, storage event still does the job. Thanks to JavaScript Mastery, Hitesh Choudhary, RoadsideCoder.com, Traversy Media, freeCodeCamp for sharing such valuable content for Frontend production-grade applications. #JavaScript #WebDevelopment #WebAPI #BroadcastChannel #localStorage #EventListener #ReactJS
Syncing Notifications Across Browser Tabs with JavaScript
More Relevant Posts
-
💡 Did You Know? JavaScript’s event loop processes tasks, microtasks, and rendering in different phases. Because of this, Promise callbacks (microtasks) run before the browser paints the next UI frame. 🌀 This is why async code with promises often executes sooner than expected. Understanding this behavior helps prevent UI glitches, race conditions, and timing bugs while building fast, responsive web apps. Mastering the event loop can greatly improve debugging and performance optimization. 🚀 #Devoticlabs #JavaScript #Didyouknow #AsyncJS #CodingTips
To view or add a comment, sign in
-
-
#Hello #Connections 👋 #100DaysOfCodeChallenge | #Day38 🚀 Project: Notes App 📌 What I built Today I built a simple and interactive Notes App where users can create and manage notes directly in the browser. Users can add a note with a heading and details, view it instantly in the notes section, and delete notes when they are no longer needed. 🛠 Technologies Used HTML5 CSS3 Tailwind CSS JavaScript (DOM Manipulation & Event Handling) ⚠ Challenge I faced Dynamically creating note cards and updating the UI whenever a note is added or deleted. ✅ How I solved it Used JavaScript arrays to store notes and a render function to dynamically generate note cards in the DOM whenever the notes list changes. 💬 Open to feedback and suggestions 🚀 🔗 Project link in comments 👇 🙏 Code Of School Avinash Gour | Ritendra Gour #FrontendDeveloper #JavaScript #HTML5 #CSS3 #TailwindCSS #WebDevelopment #100DaysOfCode #DeveloperJourney
To view or add a comment, sign in
-
Have you ever opened a webpage and noticed that the content appears instantly… but the buttons don’t work for a moment? Recently I was reading about 𝗥𝗲𝗮𝗰𝘁 𝗛𝘆𝗱𝗿𝗮𝘁𝗶𝗼𝗻, and it made me pause for a moment. When we build apps with React frameworks like 𝗡𝗲𝘅𝘁.𝗷𝘀, the page you see in the browser is often already rendered on the server. So when the page loads, the content appears very fast. You can read the text. You can see the buttons. But something interesting is happening at that moment. The page is actually 𝗷𝘂𝘀𝘁 𝗛𝗧𝗠𝗟. Buttons are visible, but the logic behind them isn’t active yet. Event handlers are not attached. State isn’t working. Then 𝗥𝗲𝗮𝗰𝘁 loads in the browser and starts connecting the JavaScript logic to that already rendered HTML. That process is called 𝗵𝘆𝗱𝗿𝗮𝘁𝗶𝗼𝗻. It’s basically the moment when a static page becomes a fully interactive React application. Understanding this small concept will help you to see why SSR makes pages feel faster, and also why sometimes we see 𝘩𝘺𝘥𝘳𝘢𝘵𝘪𝘰𝘯 𝘮𝘪𝘴𝘮𝘢𝘵𝘤𝘩 warnings. Have you ever encountered a hydration mismatch issue while working with React? #frontend #react #nextjs #html #error
To view or add a comment, sign in
-
-
React is a powerful JavaScript library used to build fast and interactive user interfaces. ⚛️ It works with components and Virtual DOM to make modern web apps smooth and efficient. #ReactJS #WebDevelopment #JavaScript #Frontend #CodingFromZero0 🚀
To view or add a comment, sign in
-
-
Built a simple Counter App using HTML, CSS, and JavaScript. Increase ➕ Decrease ➖ Reset 🔄 — works similar to cart quantity updates. This project helped me understand DOM manipulation and dynamic value updates. GitHub Repository : https://lnkd.in/gZzUcGWT Live Demo : https://lnkd.in/gYbGruAM #JavaScript #Frontend #Learning
To view or add a comment, sign in
-
🚀 Just Built a Sticky Notes Web App using HTML, CSS & JavaScript! I recently created a simple Sticky Notes application that allows users to quickly write and manage notes directly in the browser. ✨ Key Features: • Create unlimited sticky notes • Edit notes in real time • Delete notes instantly • Notes automatically saved using localStorage • Clean and simple UI layout 💡 What I learned while building this project: DOM manipulation in JavaScript Handling events like click and input Using localStorage to persist data after page refresh Dynamically creating and updating elements This project helped me understand how front-end apps manage state and user interactions without a backend. 🔗 GitHub Repository: https://lnkd.in/gZGtkcuG I’m continuing to build more mini projects to strengthen my JavaScript and frontend development skills. #WebDevelopment #JavaScript #HTML #CSS #FrontendDevelopment #CodingJourney #100DaysOfCode #GitHub #kccitm
To view or add a comment, sign in
-
🚀 Understanding useNavigate in React (Simple Explanation) While working with React Router, I came across a very useful hook — useNavigate() 👉 It allows us to navigate between pages programmatically instead of using links. This is super helpful in real-world scenarios like: • Redirecting after login/signup • Navigating after form submission • Handling protected routes 💡 Example: import { useNavigate } from "react-router-dom"; const navigate = useNavigate(); const handleLogin = () => { navigate("/dashboard"); }; 🔥 Things I found interesting: • No need for manual link clicks • Can pass data between pages • Can control browser history (e.g., prevent going back) • Supports forward/back navigation This small hook makes applications feel more dynamic and user-friendly 💻 Currently improving my React skills and building real-world projects. Let’s connect if you're also learning or building in web development 🤝 #reactjs #webdevelopment #javascript #frontend #learninginpublic
To view or add a comment, sign in
-
-
Just shipped my Day 17/30 JavaScript challenge: a fully functional To-Do List app! Built with vanilla JS, this project showcases DOM manipulation, event listeners, and dynamic element creation in action. Features include adding tasks, marking them complete with a strikethrough effect, deleting individual items, and clearing everything at once. The sleek UI is fully responsive and built with pure HTML, CSS, and JavaScript. no frameworks, just core fundamentals. Tech topics covered: querySelector, innerHTML, createElement, addEventListener, and event delegation. From image uploaders to task managers, each project peels back another layer of web development. Check it out live: https://lnkd.in/d34HUqPn #FullStackDeveloper #JavaScript #WebDevelopment #CodeGuru #FrontendDevelopment
To view or add a comment, sign in
-
Here’s a cheat sheet highlighting 19 essential tips for React: React is a JavaScript library designed for building user interfaces based on components, offering a seamless experience. It enables the creation of fast and interactive user interfaces. Advantages of React include: 1. Effortless maintenance 2. Fast rendering 3. Search engine friendly 4. Reliable development tools 5. Stable and streamlined code 6.Redux facility 7. Offers mobile application development 8.Ample community support This breakdown serves as a quick reference for the most important React components and their benefits. #react #frontendeveloper #html5 #CSS3 #webdevelopment #webdeveloper #connections #frontend #reactseamless #reacthooks #ReactJs #w3schools #LinkedIn #LinkedIncommunity #developers
To view or add a comment, sign in
-
🚀 JavaScript Bundle Bloat Killing Your Site Speed? Fix It Now! 🚀 Your Next.js/React app looks perfect... until Lighthouse gives you a 2.5s LCP and 65+ bundle size score. In 2026, bundle optimization separates amateur side-projects from production apps that actually convert. Fresh guide on javascriptdoctor.blog: "Optimizing Bundle Size in JavaScript Applications" Battle-tested techniques: ✅ Tree-shaking that actually works (ES modules only!) ✅ Dynamic imports + React.lazy for route splitting ✅ Replace lodash/moment/axios with native alternatives ✅ Brotli compression (76% smaller than Gzip) ✅ Bundle analyzers to find your real culprits ✅ Vite vs Webpack vs esbuild speed comparison Drop your bundle from 450KB → 120KB. Users stay instead of bounce. Read here: https://lnkd.in/gGZhds8b What's bloating YOUR bundle most? Lodash? Charts? Your UI library? Drop it below! 👇 #JavaScript #WebPerformance #NextJS #ReactJS #BundleOptimization
To view or add a comment, sign in
More from this author
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