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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:48:06+00:00 2026-06-09T15:48:06+00:00

I am working with Optimizely guiders.js example code: http://jeffpickhardt.com/guiders/ Though if I extract the

  • 0

I am working with Optimizely guiders.js example code:

http://jeffpickhardt.com/guiders/

Though if I extract the JavaScript code and place it in a separate file, the guiders do not load.

Here is the edited HTML:

<html>
  <head>

    <!-- guider.js requires jQuery as a prerequisite. Be sure to load guider.js AFTER jQuery. -->
    <script type="text/javascript" src="jquery-1.5.1.min.js"></script>
    <script type="text/javascript" src="guider.js"></script>
    <script type="text/javascript" src="guidedTour.js"></script>

    <link rel="stylesheet" href="guider.css" type="text/css" />
  </head>
  <body>
    <span id="clock" style="border: 2px solid #333; width: 300px; height: 200px; text-align: center;" onclick="guider.next();">
      <br />
      <img src="clock.gif" width=150 height=150 />
    </span>


  </body>
</html>

I have all the JavaScript code in guidedTour.js, in the same directory.
All .js files are also in same directory. And the code worked before extracting it in separate file.

The guiders do not load when JavaScript is in separate file.

I am getting the following error in Chrome:

“Uncaught TypeError: Cannot read property ‘clientHeight’ of null
jquery-1.5.1.min.js:16”

Trying a more recent version of jQuery throws an error on guiders.js.
Anyway it seems a different behavior than if I keep the JavaScript code in the index.html.


I have created a jsfiddle for the working code:
http://jsfiddle.net/vpMQy/

I do not know how to create a similar jsfiddle with the JavaScript in a separate file so that I can reproduce the problem.

Is it possible to put this JavaScript code in a separate file?

  • 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-09T15:48:08+00:00Added an answer on June 9, 2026 at 3:48 pm

    Always wrap your code inside the DOM ready handler

    $(document).ready(function() {
        //your code here
    });
    

    Or its shorthand

    $(function() {
        //your code here
    });
    

    Or put your scripts at the very end of the document’s body:

        //...
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
        <script type="text/javascript" src="myScript.js"></script>
     </body>
    

    And you won’t have problems manipulating them DOM before it’s ready. =]

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

Sidebar

Related Questions

Working on a small game using an HTML5 canvas, and javascript. And it's working
I'm working on a bit of code and I'm trying to optimize it as
I am working with a Javascript library (openlayers) and am trying to optimize some
Working with legacy code, I found I got are lot of statements (more than
I've just started working with a chunk of code that the authors claim is
I am working on doing some significant optimization of some machine vision code on
I'm working on a project that includes a javascript widget that can be wrapped
I am working on a relatively large set of serial code C-code libraries, which
I'm working with the code that dynamically instantiates SoapHttpClientProtocol object (proxy class) and uses
I'm trying to optimize some code working in an embedded system (FLAC decoding, Windows

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.