r/Web_Development • u/Tidal54 • Oct 24 '22
How professionals make websites nowadays?
Hi, i'm a few months into web coding, today i learned about using the inspector in google chrome just to find that websites usually use long and random codes for naming their element's classes. Since i don't think developers are manually typing this random codes, it made me wonder how professionals make websites nowadays. If i ask any web developer to build a not=so-simple (interactive, with a database) website for me, how exactly will they make the website? will they just write code in html, css and javascript? will they use any app or pc program to do that? will they use websites like wordpress to start with a template then tweak the code?
Also it would be nice to know why they are naming div classes with those random codes.
Thanks for your time.
9
u/thestepafter Oct 24 '22
Hello! I learned web development by reading the page source in the browser (like you) about 25 years ago.
A lot has changed then.
Any code you see now is the end result of many programming frameworks and libraries working together.
These frameworks and libraries take care of the repetition work. eg. Submitting payments, processing a contact form submission, ensuring visual consistency across the site.
One of the biggest challenges for people entering this industry now is knowing what framework or library to use for building a solution.
Software such as WordPress is great because it is well established and many people know how it works. There are also downsides such as the code be very poorly written, especially for plugins.
There are pros and cons to every approach. Once you learn how everything works together you will need to learn what framework or library to choose for a solution.
My recommendation is the following based on your question about a not so simple site.
Database (PostgreSQL) Backend / API (PHP with Laravel) Frontend (AlpineJS and TailwindCSS)
The above isnโt the solution for every project but learning the above will get you started and the communities around the above are pretty fantastic.
Let me know if you have any other questions and good luck! ๐
4
u/leandro_ortiz Oct 28 '22
The random codes are generated by libraries to avoid duplicated names of CSS classes. There are libraries (e.g. styled-components) used to allow CSS in javascript code, directly in the components, so they will need to generate names for the classes. Also, there is the "CSS Modules" approach, that allows you to have local CSS (repeat class names in different files, but that will be used only in the scope of these files). In this case, you will see the "friendly" class name (given by the developer) concatenated with a random number to make it unique.
About your "not-so-simple" website, I guess, you are talking about web applications (interactive websites, like an "app", but running on the browser). It really depends on the technology stack chosen...But, usually, it would probably be divided in 2 parts:
3
u/N1sFoop Oct 25 '22
classes with random codes are usually a result of CSS-in-JS libraries (like styled-components, emotion, etc).
These libraries essentially allow users of frameworks like React, Svelte, etc to write styles scoped to components in the framework. Since the components are abstractions that are removed in the build-step the scope for the style is retained by create a css class that is named a random hash for the component.
2
u/__Taco Oct 25 '22
There are a lot of answers to your question bc there are a lot of different types of websites and ways to build them.
A static website is the most simple. It won't have a database or user authentication. You can create this with just html/css/js, or from a CMS.
There are a lot of companies that start with a CMS like Wordpress or Drupal and then hire programmers to write custom code.
Then there are companies that make complex web apps where a CMS doesn't make sense. Here you would have the entire stack, back and front, that can be built many different types of ways.
As was mentioned in another comment here, the random css names come from a package (probably styled component). There are many different css packages and libraries that can be used. If you haven't yet, look into NPM and what packages are used for and how to install them into a project.
If you're a few months in and looking for a high level overview of how everything works together, I'd recommend following a fullstack tutorial where you can code along and see an entire app come to life. That may help connect a lot of dots for you and then you can start expanding your knowledge and skills from there by building other stuff. If you do this, it may be overwhelming to see all the different parts that make a full stack web application, but just remember you learn by taking small bites at at time. Figure out what you like and start there. Become good at it and then move on to another part.
1
u/hmnrbt Oct 25 '22
It really depends on what you're trying to build, but with that said, like 99% of my projects are built with wordpress and the Avada theme