A non-blocking function is any function that sets up an operation, starts that operation and then uses asynchronous resources to manage finishing the operation in the background. Asynchronous resources in the browser are things like system timers, ajax calls, CSS animations, webWorkers, etc...
In the code example you have in your question, both .slideUp()
and .slideDown()
are jQuery animations that use timers to do a little movement on each timer tick. They are asynchronous for that reason.
You can also execute some types of Javascript code in a webWorker (a separate thread). webWorkers in the browser are very limited in what they can do (they can't touch the DOM at all, for example), they must be loaded from entirely separate scripts, they can't share any variables with your main javascript and they can only communicate with the main javascript via a message passing scheme. But, you can run some types of Javascript in another thread using webWorkers. Here's a summary of webWorkers on MDN.
You can't literally make your own code just magically be asynchronous because a Javascript thread of execution runs until completion in Javascript and then when it's done, the next event in the event queue is processed. You can sometimes simulate "background processing" by doing pieces of your work in small chunks on a timer. This allows other operations (user event processing, other timer events, etc...) to be interwoven with your own execution, but it requires writing your code in an entirely different fashion so it can do work in small chunks on a timer, not just serial execution.
Here are some useful references:
Best way to iterate over an array without blocking the UI
How does JavaScript handle AJAX responses in the background?