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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:40:00+00:00 2026-05-23T12:40:00+00:00

I am referencing JavaScript as follows on an HTML page: <script type=text/javascript src=http://code.jquery.com/jquery-1.6.1.min.js></script> <script

  • 0

I am referencing JavaScript as follows on an HTML page:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&amp;region=GB"></script>
<script type="text/javascript" src="js/shared.js"></script>
<script type="text/javascript">
$('document').ready(function() {   
    // In-page code: call some functions in shared.js
});
</script>

The functions defined in shared.js are not wrapped inside $('document').ready. So:

  1. Is it safe to assume that functions defined in shared.js are available to the “in-page code”?

  2. If I pull out the in-page code into a separate file called local.js (keeping it wrapped in $('document').ready), is it still safe to assume that functions defined in shared.js are available?

  3. Finally, is the fact that I’m not wrapping shared.js inside $('document').ready a problem? I’m finding that if I do wrap it, its functions are no longer available to the in-page code.

The reason for question 3 is that I’m hitting this problem: Uncaught TypeError: Property … is not a function – after page has loaded

and wondering if it is something to do with how I’ve organised my code.

UPDATE: Thanks for the answers. It’s now clear that using $('document').ready in shared.js would remove those functions from global scope. However, I just want to clarify the original question in point 3.

Can I assume that if I do the following:

  • inside my in-page code, loaded inside $('document').ready, call a function from shared.js
  • have the function in shared.js refer to jQuery, Google Maps, or elements on my page

there will be no problems?

In other words, is it safe to assume that the page will have loaded by the time the functions inside shared.js are called, even if I’m not wrapping everything in that file inside $('document').ready?

  • 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-23T12:40:01+00:00Added an answer on May 23, 2026 at 12:40 pm

    Is it safe to assume that functions defined in shared.js are available to the “in-page code”?

    Yes, As long as those functions are injected into global scope

    If I pull out the in-page code into a separate file called local.js (keeping it wrapped in $(‘document’).ready), is it still safe to assume that functions defined in shared.js are available?

    Yes, As long as local.js is included after shared.js AND shared.js injects functions into global scope.

    Finally, is the fact that I’m not wrapping shared.js inside $(‘document’).ready a problem? I’m finding that if I do wrap it, its functions are no longer available to the in-page code.

    Wrapping functions in document.ready takes them outside of global scope.

    var foo = 4; // global
    $(function() {
      var bar = 5; // local
    });
    foo = bar; // error
    

    You need to inject variables in global scope, this is as easy as doing

    $(function() {
      /* all your code */
    
      window["SomeGlobalVariable"] = someFunctionIWantGlobal;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm referencing the jQuery autocomplete plugin code seen in this tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-use-the-jquery-ui-autocomplete-widget/ The problem
I am referencing the jQuery library, in a master page like so: <script type
i am using below code to show google map in asp.net MVC2: <script type=text/javascript
I have the following JavaScript in my HTML page referencing an HTML form on
My javascript paths work on this page: http://localhost:53049/ But not on this page: http://localhost:53049/Home/Messages
I've got some javascript code referencing var cell = event.target if (cell.cellIndex === 3)
In HTML when referencing images, css, javascript, etc... I sometimes use links without the
I'm referencing my JavaScript files before the closing body tag, hoping they will be
Any smart way of doing a root based path referencing in JavaScript, just the
I'm having some trouble with plain old JavaScript (no frameworks) in referencing my object

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.