Semi
Semi

Reputation: 123

How to find out whether a jQuery function is synchronous or not?

I have one jQuery function in my code for which I think it might be asynchronous but I couldn't find out if that's true. I have a guess that, if a function has a callback then it is asynchronous ; otherwise it is synchronous.

In my case it is the function .unwrap(). Using the logic from above I guess it is synchronous.

Upvotes: 0

Views: 54

Answers (1)

Ian
Ian

Reputation: 34489

There are a few ways you can try to do this:

  • Look at the API documentation
  • Look at the return type (if it returns a Promise it's asynchronous)
  • Look at the Source code

The particular function you're looking at, there's nothing to indicate that it's asynchronous in the docs/return type. It's just making a DOM manipulation I believe which has to be done on the main thread anyway, there's no slow code in there that could be done async.

The function itself I believe is unwrap (maybe not the exact version) but you can see there's nothing in there that looks async.

Upvotes: 1

Related Questions