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.
requirejs
7,729
questions
24
votes
6
answers
3k
views
What is the preferred method for passing server data to a RequireJS module?
Is there a preferred way to pass server data in a RequireJS module? Our current implementation looks like the following code snippets; using a 'page' object to hold any server/dynamic data and passing ...
2
votes
1
answer
385
views
What does the define() protocol outlined in CommonJS specification buy me?
I understand how things like proper name-spacing and the Module Pattern help issues associated with leaking into the global-scope.
I also completely see the value of resource dependency-management ...
4
votes
2
answers
754
views
Curl throwing ‘Promise already completed’ error
I’m currently testing various asynchronous-resource-loaders to see which one I want to use. At the moment Curl is throwing a ‘Promise already completed’ error…and their documentation says ‘this should ...
0
votes
3
answers
4k
views
RequireJS Flawed By Example?
Looking into RequireJS but unlike Head.JS which downloads in undetermined order but evaluates in a determine order, RequireJS seems different
Normally RequireJS loads and evaluates scripts in an ...
19
votes
5
answers
25k
views
requireJS an entire folder
Is it possible to "require" an entire folder using requireJS.
For example, I have a behaviors folder with a ton of behavior js files. I'd really like to be able to simply use require(['behaviors/*'],...
10
votes
3
answers
6k
views
requireJS and LESS
I'm using the client-side javascript version of LESS to compile out less code, and would like to continue using this even on the final live site (I know... bad form, but it gives me the ability to ...
0
votes
1
answer
361
views
determine which js files to load in html on the fly
I am trying to set up a project which consist of htmls and javascript/ajax - jquery with many jquery plugins.
For each of many html pages, I have to use RequireJS and here is what i want..
I want to ...
0
votes
2
answers
545
views
load modules using module name and not the file name
I have two 'define' in two separate js files.
def1.js and def2.js
define("mydefname1",["file1",...]});
define("mydefname2",["file2",....]});
I have another require statement where i check if the ...
2
votes
1
answer
1k
views
How do I make a recursive jQuery template (tmpl) availbe outside of my plugin?
I have a Json object that I'm dumping into a jQuery template (tmpl). It needs to be recursive because the Json object can be n-levels deep. This code works. However, if I wrap it in a function (it ...
54
votes
6
answers
32k
views
Using RequireJS, how do I pass in global objects or singletons around?
Let's say I am writing code at the main page level and 2 dependencies require the same instance of an object and also state that as a dependency. What is the appropriate way to go about this?
...
4
votes
1
answer
2k
views
RequireJS calling callbacks before dependencies loaded/resolved
I'm having an issue with RequireJS where my main.js script has a reference to a dependency, which is loaded but not resolved when the callback in main.js requesting this dependency is run.
My ...
4
votes
1
answer
7k
views
How to set default baseUrl
I'm using RequireJS, and all my modules reside in /payloads/backend/application.
I.e.
/payloads/backend/application/blog/newPost.js
/payloads/backend/application/blog/models/category.js
Whenever I ...
5
votes
2
answers
4k
views
ExtJs dependency management using RequireJS, LABjs (or similar)
I am trying to find examples of how to wrap ExtJs and ExtJs 'modules' up for use with a javascript dependency framework such as RequireJS or LAB.
I am working with a large ExtJs based project and ...
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
...
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'...