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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:42:08+00:00 2026-06-16T16:42:08+00:00

I am writing a framework that allows your modules to define which JS files

  • 0

I am writing a framework that allows your modules to define which JS files will be added to the page before serving it. The idea is that a module might add something like this:

require([ 'dojo/topic', 'dojo/_base/window', 'hotplate/hotDojoWidgets/AlertBar' ], function( topic, win, AlertBar
){
  globalAlertBar = new AlertBar( { background: '#FF4444' } );
  globalAlertBar.placeAt( document.body, 'first' );
  globalAlertBar.startup();

  topic.subscribe('globalAlert', function( message, displayFor ){
    displayFor = displayFor || 2500;
    globalAlertBar.set( 'message', message );
    globalAlertBar.show( displayFor );
  });
});

This allows me for example to allow other widgets around the application to publish globalAlert in order to show an alertBar.
Right now:

  • Any JS/Dojo file added to the list of JS to be loaded starts with “require”. To me, this is simply asynchronous code that will run at some point after loading. Most of the code loaded this way in the framework will wait for topics to be published, and will act accordingly
  • The “application” will simply be one of those modules, which will subscribe to a topic publishing the container’s object
  • “Proper” Dojo widgets loaded by require() will obviously use “define” — that’s business as usual, no worries there

Questions:

1) If I run ready() within one of the JS/Dojo files referenced in the page, will that be a page-level ready(), including all of the .js files loaded in the document? Or only for the files loaded by the current file?

2) I realise that the “right” way of doing things is by having only one JS file that runs require(), and have everything else loaded from that one (or even better using data-dojo-main ). However, I am trying to define modules (with server and client code) which work independently and add themselves to the page… So, is it actually bad practice, having having a bunch of files in the application page, and then having them require()‘ing and running Dojo code?

Thank you!

Merc.

P.S.
If you are curious, https://github.com/mercmobily/hotplate … the project started after a post here!

  • 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-16T16:42:09+00:00Added an answer on June 16, 2026 at 4:42 pm

    You can have as many requires per page/file/script as you would like. It’s define that should only be used once per page, as that is what makes the association between the page/script location and the module ID. define isn’t strictly for widgets – it defines a module which can be a function, constructor (class) a singleton object, or just do some work without returning anything.

    require is asynchronous; hence the callback method which fires when all teh dependencies have finished loading:

    require(modules, callback);
    

    dojo/ready is essentially “block” based. The callback will not fire until all the dependencies have loaded and the DOM is ready. It is not page based nor global – it’s quite possible to have a second require on the page that fires before the first if the first is held up waiting for the DOM.

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

Sidebar

Related Questions

I'm writing a PHP framework which allows PHP developers to create ExtJS interfaces with
I'm writing a PHP function that will delete all the files in the directory
I'm writing a web page that has a from field that allows a user
I am currently writing a small framework that will be used internally by other
I am writing a container framework that can dynamically deploy a Jar file containing
I'm writing a unittesting framework for servers that uses popen to basically execute python
I am writing a web project that uses Spring Framework 2.5 on top of
I am writing a Cocoa application that makes use of the ParseKit framework (
I am writing a simple framework for testing WinForm apps, which is running in
I'm writing a Java application that will run for a long time (essentially, it

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.