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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:58:15+00:00 2026-06-12T22:58:15+00:00

If I compile this coffeescript to javascript using coffeescript compiler on my local machine:

  • 0

If I compile this coffeescript to javascript using coffeescript compiler on my local machine:

window.App =
  Models: {}
  Views: {}
  Collections: {}
  Routers: {}
  init: ->
      Backbone.history.start()

I will end up with this generated javascript output:

// Generated by CoffeeScript 1.3.3
(function() {

  window.App = {
    Models: {},
    Views: {},
    Collections: {},
    Routers: {}
  };

  ({
    init: function() {
      var spotsList;
      spotsList = new App.Views.SpotsList();
      return Backbone.history.start();
    }
  });

}).call(this);

But, if I compile the same code in the online coffeescript to js http://js2coffee.org/ site I will get this result:

window.App = {
  Models: {},
  Views: {},
  Collections: {},
  Routers: {},
  init: function() {
    return Backbone.history.start();
  }
};

The latter seems more expected. I think this may be causing some problems in my project, but can’t tell. I know that when I call App.init() my javascript console says it doesn’t exist. Thanks for the help!

FIXED!

As @Rob W pointed out below, I had some tabs in my coffeescript code. Later I figured out it was because I had a clean install of TextMate and didn’t have it set to “Soft Tabs (spaces)”.

  • 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-12T22:58:17+00:00Added an answer on June 12, 2026 at 10:58 pm

    There are two differences between your “local” and “online” result.

    1. Local version is wrapped in a closure.
    2. Local version’s init method is dangling outside App.

    The extra closure is the default behaviour of the coffee compiler. Use the --bare flag to not get rid of the wrapper:

    coffee --bare --compile app.coffee
    

    There’s no reason for 2 to occur. Make sure that the spaces matches: If you’ve got four preceeding spaces before Models, etc, and three before init, then the output will be “wrong”.

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

Sidebar

Related Questions

I am using coffee-script.js to let me compile little snippets of coffeescript into javascript
I'm using this coffeescript to javascript converter http://coffeescript.org/ to work through a coffeescript tutorial
When trying to compile this code: #include <iostream> #include <vector> using namespace std; class
I try to compile my coffeescript file with grunt using the grunt-contrib-coffee plugin. But
I try to load image with processing.js using CoffeeScript and write this simple code:
Is there a compiler for big javascript projects, I don't want to use coffeescript
I'm now making the transition towards writing all my javascript code using Coffeescript, But
I have been reading up on Mixins using Coffeescript or just plain Javascript from
I'm using a file at app/views/api/index.js.coffee to respond_to a the js format of a
I'm very new in coffeescript and also with objects in javascript. I have this

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.