Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2010
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Loading external JS before page page load (specific span element)

    Hello. My goal is to load the JS for a specific element before displaying that element. I integrated a third part script, and it works well. I set the timer here:

    The JS is in my heading as <script type="text/javascript" src="countdownpro.js"></script>

    About mid-body I have: <span id="countdown1">2010-07-20 00:00:00 GMT+00:00</span> which allows for the setting of a target date to countdown to.

    When the page first loads it shows the above long format target time, until the js/meta tags kick in to modify it to just show the actual countdown as 00:00:00.

    I have attached countdownpro.js to this post. I tried shifting the function CD_Init() to the top of the script, and also appended it inline with the .html. I tried setting the big external script to "defer", but neither arrangement worked. I also tried placing the src file right at the top.

    I appreciate your help.
    Attached Files Attached Files
    Last edited by thejackkelly; 07-19-2010 at 02:38 PM. Reason: tried another solution

  • #2
    New Coder
    Join Date
    Jul 2010
    Posts
    61
    Thanks
    0
    Thanked 21 Times in 21 Posts
    Quote Originally Posted by thejackkelly View Post
    Hello. My goal is to load the JS for a specific element before displaying that element.
    Is that <span> of any use when JS is not available? If not, style it initially invisible and let the script display it. Otherwise place an inline script block immediately after it to hide it until the timer script loads and can redisplay it.

  • Users who have thanked RandomUser531 for this post:

    thejackkelly (07-19-2010)

  • #3
    New Coder
    Join Date
    Jul 2010
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Perfect. Thanks x3.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •