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

The Archive Base Latest Questions

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

I have a project in backbone and I am using require.js to modularize the

  • 0

I have a project in backbone and I am using require.js to modularize the code.

my main.js looks like this:

require.config({
    paths:{
        jquery:'../../../../core/js/external/jquery/jquery-1.8.2',
        underscore:'../../../../core/js/external/underscore/underscore',
        backbone:'../../../../core/js/external/backbone/backbone',
        text:'../../../../core/js/external/require/text',
        backbone_paginate:'../../../../core/js/external/backbone/backbone.pagination',
        'jquery.sprites':'../../../../core/js/sprites',
        'jquery.sprite_util':'../../../../core/js/util/spriteUtil'


    },
    shim:{
        'backbone':{
            deps:['underscore', 'jquery'],
            exports:'Backbone'
        },
        'underscore':{
            exports:'_'
        },
        'jquery.blades':{
            deps:['jquery']
        },

        'jquery.sprites':{
            deps:['jquery']
        },
        'jquery.sprite_util':{
            deps:['jquery.sprites']
        }
    }
    }
});
require(['../app'], function (AppView) {
    "use strict";
    new AppView();
});

So, here the jquery.sprites and jquery.utils are the plugins that I need to use without including them in my Views. Currently I have to include them everywhere wherever they are being used. For exaample:

define([
  'jquery',
  'underscore',
  'backbone',
  'views/SimpleNamedObjectView',
  'jquery.sprites',
  'jquery.sprite_util',


], function($, _, Backbone, SimpleNamedObjectView){
  "use strict";

Is there a way where I can access the jquery.sprites and jquery.sprite_util without including them in every view? Can it become global for all the views from main.js so that I can use the functions of these plugins without including them in all the views?
For example this.$el.getSprites(); (where the getSprites is a method of jquery.sprites)

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

    Once they’re loaded, as they’re “shimmed”, they’re going to be available globally.

    So you could call them as dependencies in your bootstrapping require call inside main.js. This would work.

    But! That’s completely against the philosophy of Require.js and AMD. Each module should declare all their dependencies so they can all be loaded individually and work as is. This would also allow for easier unit testing.

    So, yes you can, but you really shouldn’t do this.

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

Sidebar

Related Questions

I currently have two Backbone models: user and project. I would like to have
I have been using Backbone on a new project and so far have loved
I am using backbone in a project. I have a scenario where I have
I have following piece of code from my Backbone project: App.Controllers.Test = Backbone.Router.extend({ routes:
I have a rails-backbone project that generates jst.ejs templates. I'd like to include some
I'm working on a backbone.js project and I'm calling my github repo. I have
I have project asp.net with namespace test and I'm using resources (files Resource.resx and
I have project on rails 3 with multiplayer using Faye. The error block in
folks! I have project in cc.net and this project nay start by 3 ways
I am using Spring and Maven project. I have Project mit-webservices and mit-util project

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.