DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 968,873 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Why we need backend and forntend?
Maurer KrisztiΓ‘n
Maurer KrisztiΓ‘n

Posted on

Why we need backend and forntend?

Many beginner web developers do not understand the difference between the backend and the frontend, what is the difference? why is this necessary? why can't everything be written on the frontend? I will answer these in this article.

What is the difference?

In very simple terms, the frontend is what the browser loads (it runs on your computer), the backend is what the browser doesn't see (it's run by another server), but the frontend code communicates with backend via HTTP requests.

Image description

Why is this necessary?

Not all websites need a backend, but if you want to communicate with a database or other service APIs, etc. you will probably need a backend.

Secrets, tokens

If you need to communicate with a database or other api, you will soon encounter secrets / tokens. With thes secrets, anyone can access the database or anything that we use. Anyone can look at the javascript code on the frontend so e.g if the database communications were done here, the secret could be found quickly and our website would be easily hacked.

Image description

Multiplatform

Another advantage of the backends is that it can serve more than one client. Which means that if we have a website and want to make it a mobile application, we don't need to rewrite the backend, only just the frontend. We can use the same backend api, with the same code on the web, mobile, and desktop.

Image description

Performance

Not everyone has a gaming machine, or even if they do, many people view websites on mobile. The frontend code runs on your device. It is not good if a website uses your computer's resources to do bigger calculations because the user experience will be bad, it will result in a slow website or even it will be unusable.
The webpage size would be big and your browser has to download large files which results in slow and memory-heavy pages.

Image description

Business logic, value

If everything were on the frontend, then our entire code would be public, anyone could view it, download it, or copy it.

I could go on and on, but I hope you can see why we separate our code to backend and frontend. Thanks for reading this πŸ™ if you have any question leave a comment πŸ™‚

Top comments (0)

Visualizing Promises and Async/Await 🀯

async await

☝️ Check out this all-time classic DEV post