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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:58:58+00:00 2026-05-28T04:58:58+00:00

At the moment my application.js file looks like this: //= require_tree ./vendor //= require_directory

  • 0

At the moment my application.js file looks like this:

//= require_tree ./vendor
//= require_directory ./lib

I also have individual JavaScript files for individual views, e.g. home.js, user.js etc.

Do people put these files in the application.js? If so how do they activate them? Most of my JavaScript is executed from the jQuery ready event handler $(function (){ });

Obviously this does not work if they are all in the same file. How could I minify these files and access the correct ready event if they are all in the same file?

Any help or tips greatly appreciated.

  • 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-05-28T04:58:58+00:00Added an answer on May 28, 2026 at 4:58 am

    It’s fine to have multiple jQuery document ready handlers as you shouldn’t care about the order between them. You’ll need to check that the elements they work on exist before trying to attach any handlers, though.

    For example, in home.js, you might have something like

    if ($("#home_div").length) { // do some stuff on the home page } 
    

    Doing this is better than splitting up your JS and only serving some pieces on some pages, since with the compiled approach your users only have to download JS once. I think the default rails 3.1 config should minify and concatenate all of your JS in production but not in dev. If you want to enable it manually,

    config.assets.compress = true # compress js into one file
    config.assets.js_compressor = :uglifier # minify the JS (need the uglifier gem)  
    config.assets.digest = true # append hashes to filenames so you can set far-expiry headers for caching
    

    some more info, check out the “customizing the pipeline section” of the docs http://guides.rubyonrails.org/asset_pipeline.html#customizing-the-pipeline

    and this related question

    How to properly work with jQuery in Rails 3.1 asset pipeline?

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

Sidebar

Related Questions

At this moment I have an application that processes a file. My workflow is:
I have created a sizable application javascript and jQuery. However my file structure is
At the moment I have two menus in my RCP application: File and Help.
I'm attempting to create a true mosaic application. At the moment I have one
I have application reads in data from text file. Recently I realized that I
how does the structure of an external vxml grammar looks like? at the moment
I am developing an application at the moment with zend and I have seperated
I have application packed as an .ear file with ejb module inside. There is
I'm thinking about SEDA. We design at the moment an application (which is running
At the moment I am working on a project admin application in C# 3.5

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.