<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/don-t-do-this-unless-you-want-sh-t-frontend-code--hrizbxnm3" -->

---
title: Don’t do this (unless you want sh*t frontend code)
description: Messy frontend code can lead to inefficiencies and difficult debugging. Avoid common pitfalls such as using too many global variables, poor naming conventions,...
canonical: https://daily.dev/posts/don-t-do-this-unless-you-want-sh-t-frontend-code--hrizbxnm3
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Don’t do this (unless you want sh*t frontend code) | daily.dev
og:description: Messy frontend code can lead to inefficiencies and difficult debugging. Avoid common pitfalls such as using too many global variables, poor naming conventions,...
og:url: https://daily.dev/posts/don-t-do-this-unless-you-want-sh-t-frontend-code--hrizbxnm3
og:image: https://api.daily.dev/og/posts/HRIzbxNM3.png
og:image:alt: Don’t do this (unless you want sh*t frontend code)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Don’t do this (unless you want sh*t frontend code)

**[Junior Frontend Devs](https://daily.dev/sources/juniorfrontenddevs)** · [@ndeyefatoudiop](https://daily.dev/ndeyefatoudiop) · 339 upvotes · 23 comments

## Summary

Messy frontend code can lead to inefficiencies and difficult debugging. Avoid common pitfalls such as using too many global variables, poor naming conventions, and creating 'god' functions that do too much. Clean your code by organizing your folder structure, using linters, and not hardcoding configurations. Utilizing small, reusable functions and libraries can make your code more manageable and maintainable.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.frontendjoy.com/p/don-t-do-this-unless-you-want-sh-t-frontend-code>

## Community discussion

Top comments from developers on daily.dev.

**@subinc64** · 2 upvotes

> Nice one brother

**@mohammadahmadkhan** · 2 upvotes

> ### 🧼 17 Frontend Mistakes to Avoid for Clean Code:
>
> 1. **Too many global variables**
>    → Leads to unexpected bugs and harder testing. Use scoped/function variables instead.
>
> 2. **Poor naming**
>    → Avoid vague names like `x` or `data`. Use descriptive names, especially for wider scopes.
>
> 3. **“God” functions**
>    → Break large, do-it-all functions into smaller, focused ones for readability and reusability.
>
> 4. **Functions with similar-type params**
>    → Pass an object instead of multiple booleans/strings to avoid confusion.
>
> 5. **Not cleaning up resources**
>    → Always remove...

**@claudette** · 2 upvotes

> Great tips! Thank you.

**@matildaesenamgbeve** · 2 upvotes

> Thanks for sharing this @ndeyefatoudiop
> Very insightful!

**@mohemmedabdulriza** · 1 upvotes

> goodStuff()

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#react](https://daily.dev/tags/react), [#frontend](https://daily.dev/tags/frontend)

[View this post on daily.dev](https://daily.dev/posts/don-t-do-this-unless-you-want-sh-t-frontend-code--hrizbxnm3)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/don-t-do-this-unless-you-want-sh-t-frontend-code--hrizbxnm3","headline":"Don’t do this (unless you want sh*t frontend code)","text":"Shared: Don’t do this (unless you want sh*t frontend code)","url":"https://daily.dev/posts/don-t-do-this-unless-you-want-sh-t-frontend-code--hrizbxnm3","datePublished":"2025-05-03T09:43:40.139Z","dateModified":"2025-05-03T09:44:17.891Z","author":{"@type":"Person","name":"Ndeye Fatou Diop","url":"https://daily.dev/ndeyefatoudiop","image":"https://avatars2.githubusercontent.com/u/64249481?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":2190}},"image":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":339},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":23}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/mf2cbmbri"},"comment":[{"@type":"Comment","text":"Nice one brother","datePublished":"2025-05-19T03:46:54.628Z","url":"https://daily.dev/posts/HRIzbxNM3#c-u3AuTKUoT","author":{"@type":"Person","name":"SUBIN C","url":"https://daily.dev/subinc64","image":"https://avatars.githubusercontent.com/u/106572057?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"🧼 17 Frontend Mistakes to Avoid for Clean Code:\n\n\nToo many global variables\n→ Leads to unexpected bugs and harder testing. Use scoped/function variables instead.\n\n\nPoor naming\n→ Avoid vague names like x or data. Use descriptive names, especially for wider scopes.\n\n\n“God” functions\n→ Break large, do-it-all functions into smaller, focused ones for readability and reusability.\n\n\nFunctions with similar-type params\n→ Pass an object instead of multiple booleans/strings to avoid confusion.\n\n\nNot cleaning up resources\n→ Always remove listeners/intervals in React (useEffect cleanup) to prevent memory leaks.\n\n\nUnit-less variables\n→ Add units to variable names (timeoutMs, sizePx) for clarity.\n\n\nDeeply nested conditionals\n→ Flatten logic using early returns and smaller functions.\n\n\nHardcoded config\n→ Store URLs, keys, etc., in environment variables or constants.\n\n\nDead code left in comments\n→ Use version control instead. Just delete it.\n\n\nGiant utils files\n→ Split utility functions by feature and colocate where used.\n\n\nSwallowed errors\n→ Always log or handle errors properly to aid debugging and user feedback.\n\n\nOne massive file\n→ Break up large files by responsibility into logical folders.\n\n\nNo linter\n→ Use ESLint (especially with React plugins) to catch bugs and enforce consistency.\n\n\nMessy folder structure\n→ Organize by feature or domain. Avoid random file dumps.\n\n\nObvious comments\n→ Don’t comment basic code. Use better naming to express intent.\n\n\nMissing comments on weird logic\n→ Always explain hacks or workarounds with context.\n\n\nRewriting existing solutions\n→ Prefer reliable libraries (like lodash) over writing custom implementations.\n\n\n– ease of access.","datePublished":"2025-05-24T12:29:15.763Z","url":"https://daily.dev/posts/HRIzbxNM3#c-6uuoup828","author":{"@type":"Person","name":"Mohammad Ahmad Khan","url":"https://daily.dev/mohammadahmadkhan","image":"https://lh3.googleusercontent.com/a/ACg8ocItuoF1uD2tiLRDVXc69GdofSFzmuKYRllmwTnkLF6ALnWzvty4=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Great tips! Thank you.","datePublished":"2025-05-17T12:33:42.757Z","url":"https://daily.dev/posts/HRIzbxNM3#c-SFHBQdap4","author":{"@type":"Person","name":"Claudette","url":"https://daily.dev/claudette","image":"https://media.daily.dev/image/upload/s--XETtmu2---/f_auto/v1768495176/avatars/avatar_kHOkBMuMUz4W1VBvtNmLd?_a=BAMAMiiu0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Thanks for sharing this @ndeyefatoudiop\nVery insightful!","datePublished":"2025-05-18T07:10:26.396Z","url":"https://daily.dev/posts/HRIzbxNM3#c-ppuQNRDKK","author":{"@type":"Person","name":"GEM💎","url":"https://daily.dev/matildaesenamgbeve","image":"https://media.daily.dev/image/upload/s--4azHyl_d--/f_auto/v1791435813/avatars/avatar_MA1B2o3ckMjPkKaX5wFQh?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"goodStuff()","datePublished":"2025-05-20T17:30:02.000Z","url":"https://daily.dev/posts/HRIzbxNM3#c-Is9gfsPQS","author":{"@type":"Person","name":"Mohemmed Abdulriza","url":"https://daily.dev/mohemmedabdulriza","image":"https://lh3.googleusercontent.com/a/ACg8ocLX2ESBDragPsC9Py2DtgJOFNXWHcvDMIfoJSGoWq9HXYSWQg=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/juniorfrontenddevs","name":"Junior Frontend Devs"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Junior Frontend Devs","item":"https://daily.dev/squads/juniorfrontenddevs"},{"@type":"ListItem","position":3,"name":"Don’t do this (unless you want sh*t frontend code)"}]}
```

