I'm a junior web developer. My current work is on a form-based server side web application. It was set up using jQuery. I'm now the primary person working on it. In a previous job, which was more front-end-centric, they decided to move away from jQuery. It was not needed anymore.* I heard it elsewhere as well. But I sometimes feel like I would like to write my own abstractions for DOM queries and operations.
e.g. quering
var theElement = document.querySelector('.ImTheOneYoureLookingFor')
if (theElement == null) {
throw new Error('query failed: .ImTheOneYoureLookingFor')
}
// do things
I thought an abstraction would be a good idea. Maybe someting like
/** @global */
function webQuery(selector) {
// throw if not 1 found
}
But this feels like writing my own jQuery. Is this good practice? Should I care less about my code going "straight" (no detours)?
[ADDITION] *(like Greg Brughardt noted in a comment) the reason to move away from jQuery were simpler and standardized added browser API's.
createItemList(...)ordisableInapplicableFields(...)orshowHintForInputField(...). Something that has more direct connection to what your application is doing. 1/2