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

  • Home
  • SEARCH
  • 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 138665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:18:00+00:00 2026-05-11T07:18:00+00:00

I have a JS script that will be hosted on my server and that

  • 0

I have a JS script that will be hosted on my server and that others will embed in their html, i.e.

...<code for http://yoursite.example.com /> <script type="text/javascript" src="http://mysite.example.com/awesome.js" /> ...<code for http://yoursite.example.com /> 

My script declares an object with a bunch of properties accessible for use as a Javascript Object(), i.e.

<script type="text/javascript"> //From http://mysite.example.com/awesome.js alert(Awesome.Name); </script> 

Due to the load time variance, it seems I need to signal that the "Awesome" object in my script is ready. I need this to stand on its own, so no dependencies on specific JS frameworks.

Do I need to publish my own custom JS event, or does the simple fact that my script is loaded get captured by one of the existing page-level events? How else should I be doing this?

UPDATE: as a point of reference, if I include the JS in an HTML page running from http://mysite.example.com, the Awesome object is available and populated. When the JS file is included from another domain, the object is undefined at runtime.

  • 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. 2026-05-11T07:18:01+00:00Added an answer on May 11, 2026 at 7:18 am

    The javascript content of <script> tags is executed procedurally, so this

    <script type='text/javascript' src='http://mysite.com/awesome.js' /> <script type='text/javascript'>     alert(Awesome.Name); </script> 

    will only alert the contents of Awesome.Name if found in any previous script tag.

    To understand if everything has been fully loaded on the page, you have to use the DOMContentLoaded, for firefox, and ‘onreadystatechange’ for ie. Also you can simply check the load event on the window object if you don’t care about checking the DOM (could be easier).

    if ( document.addEventListener ) {     document.addEventListener( 'DOMContentLoaded', function(){          doSomething();        }, false ); } else if ( document.attachEvent ) { // IE             document.attachEvent('onreadystatechange', function(){         if ( document.readyState === 'complete' ) {             doSomething();         }     }); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 149k
  • Answers 149k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer we used Javascript to solve this: document.getElementById(value).value.length... Note that if… May 12, 2026 at 9:39 am
  • Editorial Team
    Editorial Team added an answer ADODB.Stream is not a SQL component, is an ADO component… May 12, 2026 at 9:39 am
  • Editorial Team
    Editorial Team added an answer You seem to be under the impression that databases are… May 12, 2026 at 9:39 am

Related Questions

I have a web application that uses TONS of javascript, and as usual, there
I am trying to send a php script some content to be stored in
This one is weird, I have a page that consists of a html table
So I have an 'export' application that arrives the user at an end page

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.