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 6169235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:49:27+00:00 2026-05-23T22:49:27+00:00

I have code that I’d like to run that looks something like this pseudocode:

  • 0

I have code that I’d like to run that looks something like this pseudocode:

  1. Apply some CSS style to some element

  2. Do some other action

The issue is that I need to not do the ‘other action’ until after I’m certain that the browser has actually rendered the changed CSS and will be visible to the user.

Although Javascript is single threaded, and if the ‘other action’ blocks the Javascript from executing further, I’d think that the browser would hopefully still be able to update the view with the new CSS values set in step 1, even if Javascript itself is blocked – but that doesn’t appear to be happening (the CSS changes don’t show up until after step 2 – in this case a remote service call – completes).

  • 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-05-23T22:49:28+00:00Added an answer on May 23, 2026 at 10:49 pm

    Adding to Grezzo’s comment, you can use a JS timeout of 0 to ensure the previous line of code has finished executing. This works because it puts whatever is inside the setTimeout’s closure at the very end of the internal queue of code to be run.
    E.g.

    // Update CSS  
    $('#mydiv').css({'position' : 'relative', 'top' : 0});
    setTimeout(function() {
        funcToRunAfterUIUpdate()
    }, 0);
    

    I’m too n00b on StackOverflow to post a link, I think, otherwise you can read the “MASTERING THE REFRESH() METHOD” section here: http://cubiq.org/iscroll-4

    “Here we placed the refresh call into a zero timeout, doing so we gave the browser the time to refresh itself and the new element dimensions are correctly taken. There are other ways to ensure the browser actually updated the DOM, but so far the zero-timeout has proven to be the most solid.”

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

Sidebar

Related Questions

I have code that looks something like this: Card m_currentCard; public Card CurrentCard {
I have code that, simplified down, looks like this: run = functools.partial(run, grep=options.grep, print_only=options.print_only,
I have code that looks like this: template<class T> class list { public: class
I have code that looks like this: public class A { public void doStuff()
I have code that looks like this: <div id="header"> <ul class="tabs"> <li><a href="/user/view"><span class="tab">Profile</span></a></li>
I have code that looks like below: ResourceDictionary res = (ResourceDictionary)Application.LoadComponent(new Uri(Style.xaml, UriKind.Relative)); Style
I have code that looks like this.... function Finder(id) { this.id = id; this.input
I have code that looks like this: <div class=tag>Order # :</div> <div class=data> <input
I have code that basically looks like this (it isn't actually object, but rather
I have code that looks like the following, which works fine for displaying the

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.