DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Do we really need to minify everything?

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?

Top comments (7)

Collapse
 
tombyrer profile image
Tom Byrer

No Don't release minified scripts.

For production, yes. But that should be the last step, right before final testing.

Even if one is worried about CDNs hosting your JS script directly from NPM/GitHub, jsDelivr will minify code for you; just add min:
jsdelivr.com/features

Collapse
 
waylonwalker profile image
Waylon Walker

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.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

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.

Collapse
 
waylonwalker profile image
Waylon Walker

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

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

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.
Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

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?

Collapse
 
deciduously profile image
Ben Lovy

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.