Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9072925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:17:25+00:00 2026-06-16T18:17:25+00:00

The trigger function appears to be synchronous. That is, all bound functions appear to

  • 0

The trigger function appears to be synchronous. That is, all bound functions appear to be executed in sequence, synchronously (the invoked function may do something asynchronously, but that’s not the question).

Is this true for custom and non-custom(click, hover, etc) events? Are there any events where the single threaded guarantee of Javascript does not hold true?

If it is true, can the behavior be changed to execute them asynchronously without inserting timeouts into each bound function?

Here is a sample which demonstrates The question:

var ele = $('#blah');
// Example of the bound function doing something synchronously
ele.bind('customEvent.sync', function() {
    // Do something synchronously
    window.foo = 'foo';
});

// Example of the bound function doing something asynchronously
ele.bind('customEvent.async', function() {
    window.setTimeout(function() {
        // Do something asynchronously
        window.bar = 'bar';
    }, 0);
});

// Trigger both events
ele.trigger('customEvent');

// If trigger is guaranteed to be synchronous this should alert 'foo:undefined' or possibly 'foo:bar' depending on whether the asych function was called first
// If trigger is NOT synchronous 'undefined:undefined', 'foo:undefined', 'undefined:bar', or 'foo:bar' could be alerted
alert(window.foo + ':' + window.bar);

UPDATE
See: Is JavaScript guaranteed to be single-threaded?
Custom events are guaranteed to be synchronous because of the single threaded nature of Javascript. Some built in event types may not be synchronous due to browser inconsistencies.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:17:27+00:00Added an answer on June 16, 2026 at 6:17 pm

    A lightly modified anthology of comments offered above by myself – Beetroot-Beetroot :

    • Events have no duration; providing a handler is attached, they cause a thread to start. Therefore an event, in itself, can be neither synchronous nor asynchronous. The thread that an event stimulates will always be synchronous but may kick off one or more asynchronous processes.

    • A call to .trigger() is always synchronous regardless of any asynchronous processes that might be started in the triggered event handler. When the triggered handler returns, execution reverts to the statement following .trigger(…). ie, .trigger() is a glorified function call.

    • In javascript, the current thread is absolutely guaranteed to run to completion before anything put in place with setTimeout() starts, even if the timeout duration is 0. Same with ajax – a thread that calls, say, $.ajax(...) is guaranteed to run to completion before any of the success/error/complete handlers commences, even if the server was to respond immediately.

    • Single-threadedness is inherent to ECMA-262 (javascript), ie. at any moment in time, a maximum of one thread can be running.

    Additional point :

    The acceped answer to Is javascript guaranteed to be single-threaded? is based on a false premise. No evidence is offered that javascript is not single-threaded. The comment by @KrisGiesing debunks the misunderstanding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an click function that I want to trigger outside of the function
I have the following function that is supposed to trigger anytime one of the
I have a simple video html5 tag, bound to an ended event: $('#video').show().trigger(play).bind('ended', function
The Facebook JS SDK has the equivalent of jQuery's trigger() function, FB.Event.fire that allows
I need to trigger function bar() whenever function foo() fires. I have no control
I am using a trigger function to write data into a new table in
I'm very new to trigger function. Actually this is the first time I'm using
I am basically trying to trigger a function if the footer is inside the
I am trying to get the Enter key to trigger a function when it
When I pass 'this' to an anonymous function like so: MyClass.prototype.trigger = function(){ window.setTimeout(function(){this.onTimeout();},1000);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.