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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:04:32+00:00 2026-06-14T16:04:32+00:00

A Brief Explanation This is not as basic as it sounds, so please do

  • 0

A Brief Explanation

This is not as basic as it sounds, so please do not skip to answering before you have read and understood what I am trying to do :-).

I have an object called SineMacula which contains a few base functions like so (ignore the ready function for the moment):

(function(global, $){

    // MOST CODE STRIPT OUT HERE */

    /**
     * Sine Macula Run
     * Makes it easy to write plugins for the Sine Macula library
     *
     * @param function callback
     */
    SM.run = run;
    function run(callback){
        // Call the function with the Sine Macula
        // and jQuery objects
        callback(SM, $);
    }

    /**
     * Sine Macula Ready
     * Executes code once the Sine Macula and jQuery
     * libraries are ready
     *
     * @param function callback
     */
    SM.ready = ready;
    function ready(callback){
        // Call the function with the Sine Macula
        // and jQuery objects
        jQuery(function($) {
            callback(SM, $);
        });
    }

    /**
     * Sine Macula Load
     * Load the Sine Macula Libraries and Plugins
     * into the current document
     *
     * The options:
     * - package: the package of libraries to load
     * - packageURL: a remote source to load the package details from
     * - libraries: any additional libraries to load
     *
     * @param object parameter The options for the Sine Macula load
     */
    SM.load = load;
    function load(options){
        // BUILD A QUERY HERE
        // ...
        // Complete the url by appending the query
        url = '//libraries.sinemaculammviii.com/'+query;        
        // Append the script tag to the end of the document
        script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = url;
        $('head')[0].appendChild(script);       
    }
})(this, this.jQuery);

The load() function simply loads in all relevant plugins/libraries for the page by appending a relevant script tag to the head of the page.

All the scripts in the loaded pages are run as a callback to the function called run. This ensures that both jQuery and SineMacula are passed through to the plugins.

The Problem

This is where the issue lies, because the libraries are being loaded into the SineMacula object, there is no way to detect whether they have been loaded or not.

For example, if one of the libraries contains a function plugin called setDate(), and I run:

SM.setDate()

This will not necessarily work because the setDate() function may not have been loaded into the SineMacula object yet and therefore it will return an ‘Uncaught TypeError…’.

Can anybody advise of a good adaptation to the SineMacula.ready() function to detect whether or not the libraries are present?

Please do not make suggestions to do with the jQuery.load() function, I am well aware of it.

I do not want the solution to be a callback of the function load(), unless absolutely necessary.

I hope this makes sense, if not let me know and I will post more info. Wanted to keep it as brief as possible.

Thanks in Advance

UPDATE

Forgot to mention that I have a testing page here where you can see the error I am getting and get a better understanding of what I am doing 🙂

  • 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-14T16:04:33+00:00Added an answer on June 14, 2026 at 4:04 pm

    If I understand correctly, its the user that invokes SM.run() from within their script, which then calls SM.load(), which loads other parts of the library.

    So if that’s the case, then no matter what, their script will finish executing before any other parts of the library can be loaded.

    I think what you’d need to do is have a requirement that the user have their .run() in a separate script from the rest of their code. Then you can use document.write to load the other scripts. This will cause them to load and block the next script, which would contain the rest of the user’s code:

    function load(options){
        // BUILD A QUERY HERE
        // ...
        // Complete the url by appending the query
        document.write('<scr' + 'ipt type="text/javascript" ',
                                ' src="//libraries.sinemaculammviii.com/' + query,
                                '"><\/scr' + 'ipt>');      
    }
    

    <script type="text/javascript" src="/path/to/your/lib.js"></script>
    <script type="text/javascript">
        SineMacula.load('all');
    </script>
    
    <!-- The document.write will write the new script here, and it will be loaded
             syncronously, so it will block. -->
    
    <script type="text/javascript">
        // code that uses the loaded library parts
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Brief Explanation I am unsure about the structure that I have used for this
I've run into a bit of an issue. Here's a brief explanation. I have
could someone give me a brief explanation of what is happening differently in the
Brief Idea about the flow : I have say minimum 1 and maximum 18
Brief intro about my requirement. I have an empty JSF dataTable. Now, when I
The example will give a brief explanation of what i'm talking about: AFTER INSERT,UPDATE
I need a brief explanation on how the two commands isdigit() and isalpha() work.
I'm new to PHP, so this question might best be answered by a brief
Basically, I would like a brief explanation of how I can access a SQL
I have a lot of strings like this to find and replace in visual

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.