--- author: twitter:hmillerdev link: https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md status: not-finished date: August 2, 2023 --- # Front-end Practices That Changed My Life - DEV Community #programming #web-development #software-development Hey there! My name is Hunter Miller and Ive been developing web software for about 6 years now. Along the way Ive taken many paths to produce effective software, some that worked well and some that didnt. Ive collected those that I found most influential so that maybe you can get a jump start. Although Ive had some success using "larger" patterns I find the smaller ones more powerful and better for overall quality. _By no means is this an exhaustive list. Also please excuse some of the examples, I had to make most of them up. 😂_ ## [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#general)General ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#youre-never-too-far-along-to-learnrelearn-the-fundamentals)Youre Never Too Far Along to Learn/Relearn the Fundamentals Its awesome to jump in, start building things, and get something working especially as a beginner. Without learning the fundamentals though, you will often find that you arent quite sure precisely why something is happening, leading to lots of headaches when trying to fix bugs. The fundamentals help you narrow down whats happening so that you can piece it together. For HTML that means learn the basic tags and when its appropriate to use them. For CSS that means knowing all the different properties that affect layout and how they interact together. For JS it means knowing what `this` is at all times 😂. ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#prefer-the-simplest-tech-when-possible)Prefer the Simplest Tech When Possible When building web experiences, I try and use HTML first, CSS second, and finally JS if necessary. HTML + CSS can get you really far before you have to reach for JS. Its often simpler and more performant to not have to handle such interactions in JS. ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#read-documentation-and-source-code-especially-mdn-for-the-web)Read Documentation and Source Code (Especially MDN for the web) Documentation and source code are your gateways into learning how things really work. Every time you take the time to read the documentation/source code you gain new little bits that youve never noticed before. Theres lots of functionality in the web that you probably dont know. And if you only ever read blogs, tutorials, and Stack Overflow youll never see the full potential of the tools you are using. Its especially helpful for open source libraries where authors dont always have time to write documentation. This made me a better programmer. ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#accessibility-is-necessary)Accessibility Is Necessary Without proper accessibility your site will be unusable by those who need to use screen readers, high-contrast text, keyboard navigation, etc. Taking the time to learn the accessibility features of the browser will set you up for success the next time youre trying to create a new experience. I found these people and organizations helped a lot when learning more about accessibility: - [Heydon Pickering](https://heydonworks.com/) - [Laura Kalbag](https://laurakalbag.com/) - [A11y Project](https://a11yproject.com/checklist/) - [Simply Accessible](http://simplyaccessible.com/article/listening-web-part-one-thinking-accessibility/) ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#learn-how-the-browser-loads-resources)Learn How the Browser Loads Resources This ones tricky because browsers arent always opaque on how they prioritize loading different types of resources. But you can learn a lot about performance from these people and organizations: - [CSS Wizardry by Harry Roberts](https://csswizardry.com/) - [Varvy by Patrick Sexton](https://varvy.com/pagespeed/) - [Tim Kadlec](https://timkadlec.com/) - [Filament Group](https://www.filamentgroup.com/lab/) - [web.dev](https://web.dev/fast/) ## [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#css)CSS ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#atomic-or-utilityfirst-css)Atomic or Utility-first CSS Atomic CSS is a way of structuring your CSS classes which mimics the properties and values available in CSS. At first this sounds pretty crazy. There are tons of properties in CSS and each has multiple or even infinite values, so how could this possibly work? Well, first off you dont actually produce a class for each and every value. For those properties with numerical values, we come up with a standard set to use so that will benefit us the most. For example, we might have a set of classes for various vertical margins. They might be `my-0 my-1 my-2 my-3`...where each number represents some "level" of margin. So maybe `my-1` equals `margin-top: .25rem; margin-bottom: .25rem;`, and each level after is just + .25rem. Now we have a very useful set of classes to apply pretty much whatever vertical margin we need, and we no longer have to write margins in CSS unless its an extremely specific case. Not only that, but weve given everyone who uses this a standard set of values to choose from. A third benefit is that we know exactly what the class does, theres no guesswork or hidden values. Finally, weve now opened the possibility for any element or component to have their margin changed, if the situation arises, without making a specific override in CSS. This is probably the most powerful pattern in CSS that Ive encountered, even more so than LESS/SASS/SCSS. If you want to read more about it here are some great links, [In Defense of Utility-First CSS](https://frontstuff.io/in-defense-of-utility-first-css), [Tailwind CSS](https://tailwindcss.com/docs/utility-first/), [Tachyons CSS](http://tachyons.io/), and a whole slew of articles linked at [The Case for Atomic CSS](https://johnpolacek.github.io/the-case-for-atomic-css/). ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#consistently-ordering-properties)Consistently Ordering Properties This is really small and has no actual effects on your CSS (unless its duplicate properties for fallbacks of properties that arent supported). However I find it really helpful when reading/writing CSS to stick with a consistent order. My preferred order is layout/positioning, sizing, spacing, typography, colors/visual effects, transition/animations, and then finally "miscellaneous". Within each category I try to stay ordered as well. It helps to spot bugs and speed things up. ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#single-class-specificity)Single Class Specificity I learned this the hard way after nesting way too much SASS and before I got deep into atomic CSS. I was working at a design agency building boutique level websites so everything was very creative and unsystematic or at least each component had lots of exceptions 😉. I quickly found that it was becoming difficult to override CSS I had previously written because everything varied in specificity. By flattening all of it to as close to one class level of specificity it became much easier to override properties on a class. This works hand-in-hand with atomic CSS because as long as your utility classes come last (or have important applied because lets face it if you put that class on their you wanted it) itll override the component class. This leads to much less specificity wars. ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#performant-transitions-and-animations)Performant Transitions and Animations This one is very simple, but can be annoying in practice. There are only two properties in CSS that can be reliably performant, `transform` and `opacity`. Everything else is subject to more expensive operations that can cause jank. In general I try to use only these, but I still use `color`, `background-color`, and `border-color` often in low-impact situations, like links or buttons. Read more here about [high performance animations](https://www.html5rocks.com/en/tutorials/speed/high-performance-animations/). ## [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#html)HTML ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#semantics-aka-learn-the-basic-tags)Semantics, aka Learn the Basic Tags There are so many HTML elements. Its hard to know them all and everything that they do, but they will help you build web experiences that are more accessible and maybe even help you write less CSS and JS. Proper HTML also helps your site get crawled by search engines, which helps your content get found. They are the basic bits of the web and using them properly helps you create websites that work. ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#responsive-images)Responsive Images Heres the best way to save bytes on your images. Responsive images allow you to serve just the right size to your users by giving you channels to describe images of different sizes and when those sizes will apply. Theres a great doc written by MDN that explains it [here](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images). ### [](https://dev.to/arthyn/front-end-practices-that-changed-my-life-56md#ltinputgt-ltlabelgt-interaction-ltdialoggt-ltdetailsgt-and-more) +