This will require you to look through the Extensions catalog to see if there is a public extension that does what you want.
If you can't find a publicly available extension, then you can build your own private extension to do what your custom code does.
Personally, if there isn't a publicly available extension, I normally leave the custom code alone. "If it ain't broke, don't fix it." Also, building an extension requires you to have some programming knowledge to build an extension in the way that a nodejs module is built. If you have no idea how to build such a module, then you need to invest time to learn how to do so, before you can even start building that extension.
Also, jQuery will continue to work just fine, as long as you include it in your web page itself or via a Launch rule that runs at Library Loaded or DOM Ready.