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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:21:56+00:00 2026-06-06T13:21:56+00:00

I’m using requireJS to load scripts. It has this detail in the docs :

  • 0

I’m using requireJS to load scripts. It has this detail in the docs:

The path that is used for a module name should not include the .js
extension, since the path mapping could be for a directory.

In my app, I map all of my script files in a config path, because they’re dynamically generated at runtime (my scripts start life as things like order.js but become things like order.min.b25a571965d02d9c54871b7636ca1c5e.js (this is a hash of the file contents, for cachebusting purposes).

In some cases, require will add a second .js extension to the end of these paths. Although I generate the dynamic paths on the server side and then populate the config path, I have to then write some extra javascript code to remove the .js extension from the problematic files.

Reading the requireJS docs, I really don’t understand why you’d ever want the path mapping to be used for a directory. Does this mean it’s possible to somehow load an entire directory’s worth of files in one call? I don’t get it.

Does anybody know if it’s possible to just force require to stop adding .js to file paths so I don’t have to hack around it?

thanks.

UPDATE: added some code samples as requested.

This is inside my HTML file (it’s a Scala project so we can’t write these variables directly into a .js file):

foo.js.modules = {
    order               : '@Static("javascripts/order.min.js")',
    reqwest             : 'http://5.foo.appspot.com/js/libs/reqwest',
    bean                : 'http://4.foo.appspot.com/js/libs/bean.min',
    detect              : 'order!http://4.foo.appspot.com/js/detect/detect.js',
    images              : 'order!http://4.foo.appspot.com/js/detect/images.js',
    basicTemplate       : '@Static("javascripts/libs/basicTemplate.min.js")',
    trailExpander       : '@Static("javascripts/libs/trailExpander.min.js")',
    fetchDiscussion     : '@Static("javascripts/libs/fetchDiscussion.min.js")'
    mostPopular         : '@Static("javascripts/libs/mostPopular.min.js")'
};

Then inside my main.js:

requirejs.config({
    paths: foo.js.modules
});

require([foo.js.modules.detect, foo.js.modules.images, "bean"], 
    function(detect, images, bean) {
        // do stuff
});

In the example above, I have to use the string “bean” (which refers to the require path) rather than my direct object (like the others use foo.js.modules.bar) otherwise I get the extra .js appended.

Hope this makes sense.

  • 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-06T13:21:59+00:00Added an answer on June 6, 2026 at 1:21 pm

    requirejs’ noext plugin:

    Load scripts without appending “.js” extension, useful for dynamic scripts…

    Documentation

    check the examples folder. All the info you probably need will be inside comments or on the example code itself.

    Basic usage

    Put the plugins inside the baseUrl folder (usually same folder as the main.js file) or create an alias to the plugin location:

    require.config({
        paths : {
            //create alias to plugins (not needed if plugins are on the baseUrl)
            async: 'lib/require/async',
            font: 'lib/require/font',
            goog: 'lib/require/goog',
            image: 'lib/require/image',
            json: 'lib/require/json',
            noext: 'lib/require/noext',
            mdown: 'lib/require/mdown',
            propertyParser : 'lib/require/propertyParser',
            markdownConverter : 'lib/Markdown.Converter'
        }
    });
    
    //use plugins as if they were at baseUrl
    define([
            'image!awsum.jpg',
            'json!data/foo.json',
            'noext!js/bar.php',
            'mdown!data/lorem_ipsum.md',
            'async!http://maps.google.com/maps/api/js?sensor=false',
            'goog!visualization,1,packages:[corechart,geochart]',
            'goog!search,1',
            'font!google,families:[Tangerine,Cantarell]'
        ], function(awsum, foo, bar, loremIpsum){
            //all dependencies are loaded (including gmaps and other google apis)
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the

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.