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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:31:59+00:00 2026-06-08T21:31:59+00:00

I have two coffeescript files, A and B, in the same folder. I want

  • 0

I have two coffeescript files, A and B, in the same folder. I want A to execute up to a point, then run B, then continue executing. In other words, I want this:

//in A
$("#content").html(@currentView.el)
require ['B']

//in B
if document.location.href.indexOf("showdiv") > 0
    $("#content").trigger('click')

However, if I put everything into A, it works fine:

//in A
$("#content").html(@currentView.el)

if document.location.href.indexOf("showdiv") > 0
    $("#content").trigger('click')

How can I get the first snippet to work? Is the require keyword making the compiled javascript load in parallel?

  • 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-08T21:32:01+00:00Added an answer on June 8, 2026 at 9:32 pm

    In the browser you control the load order by how you pull in your code in your html file. Here’s an example from one of my projects (in index.html, just before the closing body tag):

      <script src="vendor/jquery-1.7.2.min.js"></script>
      <script src="vendor/bs/js/bootstrap.min.js"></script>
      <script src="vendor/underscore-min.js"></script>
      <script src="vendor/backbone-min.js"></script>
      <script src="vendor/pouch.alpha.js"></script>
      <script src="vendor/backbone-pouchdb.js"></script>
      <script src="vendor/backbone-couchdb.js"></script>
    
      <script src="js/main.js"></script>
    

    The last one is the one that kicks things off, similar to the “main” function in C if that makes any sense to you. In it, there is this construct (compiled to js of course):

    $(document).ready ->
      # Initialization code goes here
    

    The initialization code will either include all the code in your original posting (minus the require calls which do not exist in the browser), or call a function containing it. The reason you need to delay your script execution in the manner shown above is to delay execution until all the code has loaded properly.

    There are other ways to do it, and one you may be confusing with is the concept of Javascript AMD (Asynchronous Module Definition) and you can read more about it on one of the libraries for it (RequireJS – http://requirejs.org). But my advice would be to master the basics as I’ve described above before trying to get AMD (with tools) going.

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

Sidebar

Related Questions

I have two inputs with the same date, but i want to separate the
Have two folders with approx. 150 java property files. In a shell script, how
I have two files client.php and server.php. The client file send a HTTP request
I have two columns say Main and Sub . (they can be of same
I have two update panels on a page. And I want to update both
I have two classes Order and Items I want a method like this class
Have two events: $('body').mouseup(function(e){} and $('.toggle').click(function(e){} I only want one of these to trigger.
I have two Macs, and a shared folder on a third Windows computer. If
Have two fields start and end, both are dates, I want to write a
Have two sets of data (two tables) for patient records, one 1999-2003, the other

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.