⚑ As a Web Developer, you should always minify your CSS/JS!

Minifying your code is crucial to ensure your website is fast and good performing for modern SEO!

πŸ‘‡ Learn how to minify your CSS/JS in seconds!
1️⃣ Why you should minify CSS/JS

Minifying your CSS/JS reduces its size, no unnecessary white spaces, and no comments are loaded.
Those changes can drastically decrease the payload size of your request.

For JS, it even can strip down function and variable names!
2️⃣ How much does minify save you?

In our example below, we have a simple portfolio page.

The default CSS was not minified and had a size of 2.1 kb.
The minified outcome is 1.1kb, which is nearly 50% savings.

Imagine those savings on greater websites! 🀯 Minify saved up to 1kb!
3️⃣ How to view minified code in your Browser?

The Chrome DEV console offers you to view directly minified code un-minified.

This works easy for CSS and can be hard for JS as it also transforms your function and variable names! Toggle button for minify in Chrome DEV Console
4️⃣ How to minify your CSS/JS online?

There are various websites to minify your CSS and JS quickly.
Some of the most known are:

- minifier.org
- cssminifier.com
- javascript-minifier.com

There are plenty more. These are just some examples.

πŸ‘‡
You may do not want to minimize your CSS always by hand.

It is recommended to set up a CI that can handle automatically minifying your CSS and JS.
It does not matter which CI tool you are using in the end.
Having just the savings, in general, can be a huge boost!
5️⃣ CI minifier for CSS

Here is a list of minifier for CSS:

- Webpack: webpack.js.org/plugins/css-mi…
- Gulp: github.com/scniro/gulp-cl…
- Grunt: github.com/gruntjs/grunt-…

And there are many more. Those are just examples! Add your favorites in the comment if I missed them πŸ™Œ
6️⃣ CI minifier for JS

Here is a list of minifier for JS:

- Webpack, built-in: webpack.js.org/configuration/…
- Gulp uglify: npmjs.com/package/gulp-u…
- Grunt: github.com/gruntjs/grunt-…
- uglify-js: npmjs.com/package/uglify…

Yes, if you haven't noticed it, use uglify πŸ˜…
This is the third thread breaking down some methods to boost your website's performance with ease and no hassle. πŸ™Œ

In 2 days, I will post another thread with details on optimizing images for your website and delivering them as fast as possible! ⚑
βœ… Done

If you found this useful, consider following me @michaelketzer and retweet the first tweet! πŸ™

Did I miss something? Please let me know πŸ™

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Michael Ketzer πŸš€

Michael Ketzer πŸš€ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @michaelketzer

4 Aug
⚑ Every Web Developer should know how to create next-gen image formats

Serving your images in next-gen formats is crucial to ensure your performance is fantastic and loads fast for any of your users.

πŸ‘‡ Learn how to create images in the next-gen format in seconds
1️⃣ What are next-gen formats?

Next-gen formats are image formats such as
- WebP
- AVIF
- JPEG 2000
- JPEG XR

We will focus on WebP as this has the best support across all browsers and is most used!
2️⃣ What is WebP?

WebP is a next-gen image format published by google in 2010. It creates lossless images that are 26% smaller than PNG's and lossy images 25-34% smaller.

In reality, I have seen over 40% smaller sizes already.

And WebP supports transparency! ⚑

πŸ‘‡
Read 14 tweets
2 Aug
⚑ Every Web Developer should know what Critical CSS is and how to use it

Using critical CSS and defer non-critical CSS can boost your website's performance which is becoming more important!

πŸ‘‡ Learn how to extract critical CSS and defer non-critical CSS
▢️ What exactly is critical CSS?

Critical CSS is any CSS that is relevant for elements being displayed above the fold. Above the fold are all elements that are rendered within a user's viewport when visiting your website. Anything else is non-critical! Visualisation what means above the fold and what not
▢️ How can you extract your critical CSS?

One of the easiest methods to get quickly started is by using an online tool.
There are plenty out there.

For our example, we will use sitelocity.com/critical-path-….
Just enter your domain, and generate your critical CSS in a second. Generated critical css
Read 9 tweets
1 Aug
⚑ Every Web Developer should know how to find unused code in their application

A lot of unused code can slow down your website. It is blocking the main thread with parsing, compiling, and executing the code.

πŸ‘‡ Learn how to find unused code in seconds
1️⃣ Using chrome dev tools

Chrome dev tools have a coverage tab that can reveal unused CSS. You can access this tab by:

- Open Dev Tools
- STRG+ Shift + P
- Searching "Coverage"
- Select "Start instrumenting coverage and reload the page"

πŸ‘‡
This does open a new tab in Chrome and displays all the files that may include unused code.

You can already learn a lot from these files alone, as in our example, there are fonts loaded that are never used. Easy to clean up.

πŸ‘‡ Coverage Tab in Chrome Dev Tools
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(