Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: JavaScript

JavaScript

Why forEach Breaks Async Logic (and How to Fix It)

- 24.01.26 - ErcanOPAK comment on Why forEach Breaks Async Logic (and How to Fix It)

Array.forEach() does not await async functions.This silently causes race conditions and partial execution. // ❌ This does NOT wait items.forEach(async item => { await process(item); }); // ✅ Correct for (const item of items) { await process(item); } Why this mattersforEach ignores promises. Errors get swallowed, execution order breaks.

Read More
Ajax / JavaScript

Ajax Requests Succeed but UI Never Updates

- 23.01.26 - ErcanOPAK comment on Ajax Requests Succeed but UI Never Updates

Network OK, UI frozen. Why it happensState updated outside render cycle. Why it mattersUsers see stale data. Vital fix Centralize state updates.

Read More
JavaScript

JavaScript Objects Grow Memory Over Time

- 23.01.26 - ErcanOPAK comment on JavaScript Objects Grow Memory Over Time

No leaks visible. Why it happensDetached DOM references. Why it mattersLong sessions slow down. Vital fix Null references explicitly.

Read More
JavaScript

JavaScript Timers Drift Over Time

- 22.01.26 - ErcanOPAK comment on JavaScript Timers Drift Over Time

Intervals lose accuracy. Why it happenssetInterval stacks delays. Why it mattersAnimations and polling drift. Smart fixUse recursive setTimeout.

Read More
JavaScript

JavaScript Memory Grows Without Errors

- 21.01.26 - ErcanOPAK comment on JavaScript Memory Grows Without Errors

No crash, slow death. Why it happensDetached DOM references. Why it mattersLong-running apps degrade silently. Smart fixClear references on element removal. element = null;  

Read More
Ajax / JavaScript

Ajax Forms Submit Twice

- 18.01.26 - ErcanOPAK comment on Ajax Forms Submit Twice

Users click once. WhyButton not disabled during request. TipDisable button until response. button.disabled = true;  

Read More
JavaScript

JavaScript Loops Feel Slow

- 18.01.26 - ErcanOPAK comment on JavaScript Loops Feel Slow

Small loops, big impact. WhyDOM updates inside loops. TipBatch DOM changes. const fragment = document.createDocumentFragment();  

Read More
Ajax / JavaScript

Ajax Requests Succeed but Data Is Stale

- 16.01.26 - ErcanOPAK comment on Ajax Requests Succeed but Data Is Stale

Correct response, old UI. WhyClient-side caching assumptions. TipExplicitly control cache headers.

Read More
JavaScript

JavaScript Apps Become Sluggish After Navigation

- 16.01.26 - ErcanOPAK comment on JavaScript Apps Become Sluggish After Navigation

SPA feels heavier over time. WhyEvent listeners not removed. TipAlways clean up listeners on teardown.

Read More
Ajax / JavaScript

Ajax Calls Succeed but UI Feels Delayed

- 15.01.26 - ErcanOPAK comment on Ajax Calls Succeed but UI Feels Delayed

Data arrives, UI lags. WhyDOM updates are too frequent. TipBatch DOM updates after Ajax responses.

Read More
JavaScript

JavaScript Functions Accidentally Reallocate Memory

- 15.01.26 - ErcanOPAK comment on JavaScript Functions Accidentally Reallocate Memory

Same logic, rising memory. WhyInline object creation inside loops. TipMove static objects outside loops. const config = {}; for (…) { use(config); }  

Read More
JavaScript

JavaScript Code Becomes Unpredictable Over Time

- 14.01.26 - ErcanOPAK comment on JavaScript Code Becomes Unpredictable Over Time

Same code, different behavior. WhyImplicit type coercion. TipUse strict comparisons everywhere. if (value === 0) { }  

Read More
Ajax / JavaScript

Ajax Requests Work but Drain Battery on Mobile

- 13.01.26 - ErcanOPAK comment on Ajax Requests Work but Drain Battery on Mobile

Data loads fine, battery suffers. WhyPolling instead of event-driven updates. Tip Use push or conditional polling.

Read More
JavaScript

JavaScript Event Listeners Slowly Degrade Performance

- 13.01.26 - ErcanOPAK comment on JavaScript Event Listeners Slowly Degrade Performance

Page feels heavier over time. WhyListeners accumulate without cleanup. Tip Remove listeners when components unmount.

Read More
Ajax / JavaScript

Ajax Calls Block UI Under Load

- 12.01.26 - ErcanOPAK comment on Ajax Calls Block UI Under Load

UI freezes briefly. WhyHeavy JSON parsing on main thread. Tip Offload parsing to Web Workers.

Read More
JavaScript

JavaScript Objects Grow Without You Noticing

- 12.01.26 - ErcanOPAK comment on JavaScript Objects Grow Without You Noticing

No obvious leaks. WhyLong-lived references in closures. Tip Explicitly null references after use.

Read More
Ajax / JavaScript

Ajax Requests Randomly Fail on Mobile

- 11.01.26 - ErcanOPAK comment on Ajax Requests Randomly Fail on Mobile

Desktop fine. Mobile broken. WhyMobile networks aggressively drop idle connections. Fix Set shorter request timeouts.

Read More
JavaScript

JavaScript Arrays Grow Memory Over Time

- 11.01.26 - ErcanOPAK comment on JavaScript Arrays Grow Memory Over Time

No leak detected. WhyReferences are retained by closures. Fix Explicitly clear arrays when lifecycle ends.

Read More
Ajax / JavaScript

Ajax Requests Succeed but Data Is Outdated

- 07.01.26 - ErcanOPAK comment on Ajax Requests Succeed but Data Is Outdated

Server updated, client not. WhyAggressive caching on GET requests. Fix Add cache-busting headers or query tokens.

Read More
JavaScript

JavaScript Timers Drift Over Time

- 07.01.26 - ErcanOPAK comment on JavaScript Timers Drift Over Time

Intervals slowly become inaccurate. WhysetInterval depends on event loop timing. Fix Recalculate timing based on actual timestamps.

Read More
Ajax / JavaScript

Ajax Calls Fail Only Behind Load Balancer

- 06.01.26 - ErcanOPAK comment on Ajax Calls Fail Only Behind Load Balancer

Direct calls succeed. WhyMissing forwarded headers. FixForward X-Forwarded-Proto.

Read More
JavaScript

JavaScript Memory Usage Keeps Growing

- 06.01.26 - ErcanOPAK comment on JavaScript Memory Usage Keeps Growing

No visible leaks. WhyDetached DOM nodes remain referenced. FixExplicitly null unused references.

Read More
Ajax / JavaScript

Ajax Requests Randomly Return Empty Responses

- 05.01.26 - ErcanOPAK comment on Ajax Requests Randomly Return Empty Responses

No errors, no data. WhyServer closes connection before body flush. FixExplicitly flush response on server side.

Read More
JavaScript

JavaScript Timers Drift Over Time

- 05.01.26 - ErcanOPAK comment on JavaScript Timers Drift Over Time

Intervals lose accuracy. WhysetInterval accumulates delay. Fix Use recursive setTimeout with timestamps.

Read More
Ajax / JavaScript

Ajax Calls Fail When Tab Is Backgrounded

- 04.01.26 - ErcanOPAK comment on Ajax Calls Fail When Tab Is Backgrounded

Works when tab is active. WhyBrowser throttles background requests. FixUse Background Sync or retry logic.

Read More
JavaScript

JavaScript State Updates Lag Behind UI

- 04.01.26 - ErcanOPAK comment on JavaScript State Updates Lag Behind UI

UI renders stale data. WhyState mutations are asynchronous. Fix setState(prev => ({ …prev, value }));  

Read More
JavaScript

Ajax Calls Fail Only on Slow Networks

- 03.01.26 - ErcanOPAK comment on Ajax Calls Fail Only on Slow Networks

Fast internet hides the bug. WhyRace conditions between requests. FixCancel in-flight requests before sending new ones.

Read More
JavaScript

JavaScript Event Listeners Multiply Silently

- 03.01.26 - ErcanOPAK comment on JavaScript Event Listeners Multiply Silently

One click triggers multiple handlers. WhyListeners added repeatedly without removal. Fix element.removeEventListener(‘click’, handler);  

Read More
Ajax / JavaScript

Ajax Works Locally but Fails in Production

- 03.01.26 - ErcanOPAK comment on Ajax Works Locally but Fails in Production

No errors, no data. WhyCORS preflight blocked. FixAllow OPTIONS requests on server.

Read More
JavaScript

JavaScript Async Loops Fail Silently

- 03.01.26 - ErcanOPAK comment on JavaScript Async Loops Fail Silently

Code runs, logic breaks. WhyforEach ignores await. Fix for (const item of items) { await process(item); }  

Read More
Page 3 of 6
« Previous 1 2 3 4 5 6 Next »

Posts pagination

« Previous 1 2 3 4 5 6 Next »
June 2026
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  
« May    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (954)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (807)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (580)
  • Add Constraint to SQL Table to ensure email contains @ (580)
  • Average of all values in a column that are not zero in SQL (541)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (506)
  • Find numbers with more than two decimal places in SQL (455)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files
  • Ajax: Add Custom Headers to Fetch Requests
  • JavaScript: Use console.table to Display Arrays as Tables
  • HTML: Use Spellcheck Attribute to Enable Browser Spell Check
  • CSS: Use user-select to Prevent Text Selection
  • Windows 11: Use Snipping Tool for Instant Screenshots

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (954)
  • How to add default value for Entity Framework migrations for DateTime and Bool (882)
  • Get the First and Last Word from a String or Sentence in SQL (838)
  • How to select distinct rows in a datatable in C# (808)
  • How to make theater mode the default for Youtube (807)

Recent Posts

  • C#: Use String Interpolation Instead of Concatenation
  • C#: Use Tuples to Return Multiple Values from Methods
  • SQL: Use ISNULL and NULLIF for Smart NULL Handling
  • .NET Core: Use Data Annotations for Model Validation
  • Git: Use Git Clean to Remove Untracked Files

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com