Hacker News new | ask | show | jobs
by etatester 10 days ago
The problem with jQuery is that it swallows all errors. Dead code remains and you're none the wiser. That's only ok if you ship 2 KB of JS, at which point You Might Not Need jQuery either.

$('.mispell').hide()

No error. Just silent. This is why jQuery is not a good library other than for 2010 cross-browser development.

1 comments

> none the wiser

Wouldn't you notice with your eyes the thing didn't hide as expected?

Silent errors are by design I recall. Confirming with nearest AI... yep and a good explanation, please excuse the AI paste:

  A selector is treated like a query that returns a collection (which can legitimately be empty). Applying an action to zero items isn’t an error it’s just a no-op. This is similar to how CSS works (no harm if no .foo) or how many collection methods work in other languages.