Skip to content
loading...

Do we really need to minify everything?

twitter logo github logo ・1 min read  

Also,

  • Is Node.js essential for frontend dev (or fullstack), nowadays?
  • How do non-Node (e.g. PHP, Python, Ruby, Go) optimize for SEO?
  • Even if I use Node.js bundlers, how do I audit / optimize other aspects of SEO?
twitter logo DISCUSS (10)
markdown guide
 

Minification - yes! It helps greatly decrease file size and load times. This is a win for anyone. Made more so by the fact not everyone has 4/5G phones and are limited on data.

  • Is Node.js essential? No, nor is Angular, Vue, or React. But those systems can greatly help cut out the boilerplate work and do heavy lifting for you.

  • Those languages you listed regarding SEO are back-end. There are front-end systems the use (Blade or Twig, for example in PHP). But those aren't really the concern for the languages, that's left up to the front-end and how pages are displayed and URLS are handled.

 

I definitely mean Python dev handwrite JavaScript in <script> tags or *.js. I used to do that in the past, with jQuery as well. (And actually, there is one more concern -- Is it safe to use let or const in a <script> tag without a bundler?)

I also used to handwrite *.css without minification as well.

If you use Blade / Twig / Jinja / GoHtml, HTML-minification is the default. But if you use *.html? extension, how do you minify it without Node.js?

Is Node.js essential? No.

What do you usually use, if you don't have Webpack / Parcel / Gulp / Grunt, etc.? Also, CSS, or do you use preprocessors?

 

You can use a locally installed CLI tool to run the minification, and add it to your build pipeline (or Makefile or shell script or whatever ya got).

That said, it's convenient to be able to use npm to hook everything up, and obviously node has html-minifier readily available. I've used it in projects with virtually no JavaScript just for the build tooling, it disappears in the deployed bundle.

 

I would say minifying is well worth the effort. Though I use Lit-Element, which means it's basically impossible to serve my JS without a transpiler anyway (cuz import paths). So I use Webpack to both bundle and minify. It's nice (albeit massive dependencies) and my config is only like 15 lines.

I would say NPM is essential for a modern frontend, because (at least as far as I know), all the cool JS stuff is distributed as NPM packages, and so you'll be using NPM at least to install client libraries pretty much regardless of what else is in your stack.

As for Node besides NPM though, I'd say avoid. To be fair, I don't have any real experience with it, but why someone would want to use Javascript as their backend language is kinda beyond me TBH. Saner languages like Python and Go can do anything Node can do as far as the backend, and there are frameworks like Django (for Python) that can pull a huge amount of weight with features like a database abstraction layer that can - get this - autogenerate your SQL migrations.

How do non-Node (e.g. PHP, Python, Ruby, Go) optimize for SEO?

Well, the language the server is written in doesn't have much to do with SEO IMO. Unless you just mean performance, but in that area Node probably won't perform very well compared to something like Go (it might perform better than the other dynamic ones). And the backend language is still not as important as other things that affect performance (ie. minifying, gzipping text, using image formats with good compression).

Even if I use Node.js bundlers, how do I audit / optimize other aspects of SEO?

SEO is a huge and complicated topic that can't be covered in comments here. I learned what I know about SEO mostly from reading Moz and Ahrefs and other sites that teach about it, and some from Google Search console, but after the hundreds of hours I've spent learning about SEO, I still think I know less than half of what there is.

 

Though I use Lit-Element, which means it's basically impossible to serve my JS without a transpiler anyway (cuz import paths).

Can't you use <script type="module">? Or try snowpack.dev/#litelement. If you need minify, snowpack --optimize is there.

Node probably won't perform very well compared to something like Go

I have some aversion to Golang.

  • All variable types have an initial value, unless you declare a pointer
  • JSON (public) keys start with upper case.
  • Goroutine is there. Otherwise you cannot control multiprocessing.
 

Can't you use <script type="module">? Or try snowpack.dev/#litelement. If you need minify, snowpack --optimize is there.

<script type="module"> works, but needs the absolute URL of the module, and AFAIK lit-element is written with internal files importing each other by relative paths. I hadn't heard of snowpack. It sounds neat. I'm not planning to put work into improving my (already working) tooling in the near future, but I might look into it sometime.

Having an aversion to Golang is fair. I'm not a big fan of it either. But in general, the language the backend is written in isn't the biggest factor in the performance users see (the amount of network traffic is more important), and performance is in turn not the biggest factor in SEO (I'm no SEO expert, but as far as I know it's a pretty small one). So you can really use almost any language you want on the backend.

 

There are a number of minifiers in most languages, though I think it would be hard to implement inside inline <script /> tags. If it's just a few lines don't worry. If it grows, it's not to hard to pull it into its own .js file, minify it to .min.js then load that.

 

Maybe, but even the most popular WordPress doesn't seem to minify anything...

What are the tools most popular for Django devs use, for example? I'd like to hear that.

 

Wordpress wouldn't be the best example of optimization around.

 

I don't know about Django but searching minify js with python has a number of possible options. Maybe someome with more Django experience will chime in

Classic DEV Post from Jan 4 '19

BDD rather than TDD: Result-Oriented Testing

Pacharapol Withayasakpunt profile image
Currently interested in TypeScript, Vue, Kotlin and Python. Looking forward to learning ML, though.