Hacker News new | ask | show | jobs
by human 1989 days ago
I’d be careful about premature optimization. If you can write your code 2x faster by using jQuery, by all means do it. Eventually, if needed, you could rewrite your JS to be free of jQuery, but it would not be a priority for me. Dev speed if more important than load speed for me.
2 comments

That’s not premature optimization:

https://en.m.wikipedia.org/wiki/Program_optimization#When_to...

If your code can execute 10x faster without jQuery then the optimization is not premature. If a developer takes twice as long to write any code the problem isn’t optimizations at all.

> If your code can execute 10x faster without jQuery then the optimization is not premature.

One could argue that it is premature if the code doesn't _need_ to run 10x faster.

One could also argue that driving to work is premature if you have two perfectly good legs. All ridiculousness aside a person can invent any absurd excuse to hide from the common practices of their profession.
"optimization - an act, process, or methodology of making something (such as a design, system, or decision) as fully perfect, functional, or effective as possible"

If you optimize process of delivering feature to the end user then using JQuery is optimization and not premature. It does not have to be optimization of runtime/load time.

What we need is a Jquery-to-VanillaJS transpiler.
Uh, what do you think jQuery is written in?
jQuery is written in JS, but if your code is using jQuery functions you are not writing "vanilla JS" anymore. Otherwise we wouldn't need the term "vanilla JS".

What I meant was inlining the jQuery calls to their equivalent JS snippets, removing the need for including a 80K library if you are not overly dependent on jQuery. It was also a tongue-in-cheek comment.

The point is doing the translation on the server.