Skip to main content

Questions tagged [requirejs]

RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node.js. If you are using the require call that comes bundled with Node.js then you are NOT using RequireJS. Please do not use this tag for such cases. Use the require tag instead.

2 votes
1 answer
2k views

Using the optimizer in requirejs to group and load files

We have just started using requirejs in our project and we are loving it. Currently we are just using it to manage our many jQuery plugins the site runs on, so are barely scratching the surface of its ...
Ad Taylor's user avatar
  • 2,775
13 votes
3 answers
12k views

Requirejs loading plugins

I'm trying to load a plugin using requirejs but occasionally get an error, "$.fn is undefined" but if I reload the page the error disappears almost like now jquery is cached the problem is removed. I'...
FlimFlam's user avatar
  • 493
4 votes
1 answer
9k views

How to load a script synchronously with RequireJS

I am using RequireJS in ASP.NET. There is a user control that includes a script file, and registers a startup script in order to initialize itself. Here's the generated code: <script src="script/...
alekop's user avatar
  • 2,926
2 votes
1 answer
4k views

requireJS : Best way to add jQuery plugins?

I am having trouble working out the best way to add a jquery plugin when using requireJS to structure my javascript. The plugins seem to be recognised before I optimize my scripts but then after ...
wilsonpage's user avatar
  • 17.5k
3 votes
1 answer
6k views

RequireJS : Problem including jquery easing pack after optimization

I want to include the jquery easing pack into my application. Before requireJS files have been 'optimized' it works fine. Now I am using the optimized version when ever I call an animation that uses ...
wilsonpage's user avatar
  • 17.5k
0 votes
1 answer
6k views

requireJS Optimization : "Uncaught TypeError: undefined is not a function"

I am using requireJS for the first time. I got it working fine then came to optimize the files to minify and concatenate and now I get the error "Uncaught TypeError: undefined is not a function" the ...
wilsonpage's user avatar
  • 17.5k
1 vote
1 answer
795 views

RequireJS Optimization Reference Error

I am using RequireJS to organise my JS files. I am attempting optimize my files into one main JS file. I am using the following command to do this: /home/plugins/requireJS/build/build.sh name=main ...
Kit's user avatar
  • 4,095
9 votes
4 answers
3k views

requireJS : How to structure Javascript for an entire site?

I have 3000+ lines of javascript that I need to get into a sensible/maintainable structure. I have chosen to use requireJS as it has been recommend to me by a few people. I have a bunch of variables ...
wilsonpage's user avatar
  • 17.5k
2 votes
1 answer
3k views

requirejs - how can I get the "baseUrl" info from within a plugin?

I'm building requirejs plugins and loading them on my page. On my page, however, I'm setting a baseUrl value, so that I can just load plugins with paths like "tools/foo" instead of "/static/js/blah/...
chrispitzer's user avatar
  • 1,049
9 votes
5 answers
3k views

Getting jsdoc and Crockford's design patterns to get along

I'm using Douglas Crockford's design pattern to implement private, privileged and public methods. It basically looks something like this (using RequireJS): define(function () { return function () ...
n3rd's user avatar
  • 6,049
138 votes
4 answers
33k views

What's the difference between Require.js and simply creating a <script> element in the DOM? [closed]

What's the difference between using Require.JS amd simply creating a <script> element in the DOM? My understanding of Require.JS is that it offers the ability to load dependencies, but can this ...
maxedison's user avatar
  • 17.5k
80 votes
7 answers
31k views

How to handle circular dependencies with RequireJS/AMD?

In my system, I have a number of "classes" loaded in the browser each a separate files during development, and concatenated together for production. As they are loaded, they initialize a property on a ...
avernet's user avatar
  • 31.5k
68 votes
3 answers
56k views

RequireJS: How to define modules that contain a single "class"?

I have a number of JavaScript "classes" each implemented in its own JavaScript file. For development those files are loaded individually, and for production they are concatenated, but in both cases I ...
avernet's user avatar
  • 31.5k
21 votes
3 answers
10k views

Use requirejs and jquery, without clobbering global jquery?

I'm using requirejs for the first time on a project. I'm working in an environment that has a lot of Javascript in place already, and I'm looking for clean ways to introduce my own code. The problem ...
Wheeyls's user avatar
  • 1,012
1 vote
1 answer
1k views

Why is RequireJS not working when using priority?

When using RequireJS without "priority" it works: require( {}, [ 'js/libs/jquery/jquery-1.4.4.js', 'js/libs/utils.js', 'js/app/app.index.js', 'js/app/app.framework.js', 'js/...
Sam3k's user avatar
  • 950

15 30 50 per page