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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:01:56+00:00 2026-05-23T09:01:56+00:00

I have a utility that draws a simple arc, either using SVG or, as

  • 0

I have a utility that draws a simple arc, either using SVG or, as a fallback, Canvas. (An early version can be found in my Raphael Arcs Project on my website.

To accomodate a mobile solution, I recently added code to monitor the size of the container and, if it changes, to re-draw the image to fit the newly sized container. This addition uses only the size of the containing DIV; the code adds either a SVG or Canvas object to the DIV.

Repeatedly reloading the page, however, sometimes the DIV layout isn’t ready even when $(document).ready says it is. This seems to be most prevalent under Chrome; I’ve seen it only once with Opera and never with Firefox 3.6. The height and width of the containing DIV come back as zero.

If you load the link above in Chrome and hit reload, every tenth hit or so the Canvas demo will show a similar flaw: it will be sized width: 100% of viewport, height: 300px, and the demo will not draw correctly.

I’ve looked through the jQuery documentation and it seems to insist that $(document).ready() ought to be enough. I’d rather not have 12% of my users experience a browser-related failure. Other than writing my own layout probe (a spinning Timeout asking, over and over, “is the container sized yet?”), is there a common technique or library to assure that not only is the DOM loaded but the layout manager has settled?

[EDIT]

I’ve ended up doing something like this (code is Coffeescript):

$(document).ready ->
    $('.wrapper').each ->
        demo = =>
            c = new CanvasArc $('.canvas_demo', this)
            c.sweep(1.0)
            r = new RaphaelArc $('.raphael_demo', this)
            r.sweep(1.0)
        scan = =>
            if $('.canvas_demo', this).height()
                demo()
            else
                setTimeout(scan, 100)
        scan()

I really shouldn’t have to do that.

  • 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-23T09:01:57+00:00Added an answer on May 23, 2026 at 9:01 am

    You are right that you shouldn’t have to work around this. The answer is hidden in the .ready() section:

    When using scripts that rely on the value of CSS style properties, it’s important to reference external stylesheets or embed style elements before referencing the scripts.

    So all you need to do is include your CSS first and then your scripts. This way, your ready-event handler isn’t even being set until after the CSS has been loaded.

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

Sidebar

Related Questions

I have a small command line utility project that I'm using Maven to manage.
I have a rather simple threading question. I'm writing a simple utility that will
I have a utility that I put together that uses the .NET Framework to
Okay, here's the scenario. I have a utility that processes tons of records, and
I have a small utility that I use to download an MP3 file from
I have a little utility that does a search of a number of files.
I have a utility (grep) that gives me a list of filenames and a
At the company I work for we have a Utility project that is referenced
I have a command-line utility that gets quite a bit of downloads from my
I have some code that gives a user id to a utility that then

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.