4 ms·
Minor nitpick which might simplify your life - instead of declaring dependencies in the header (i.e. define(['xxx'],..)), just use any of your dependencies with
by hippich 13y ago
Minor nitpick which might simplify your life - instead of declaring dependencies in the header (i.e. define(['xxx'],..)), just use any of your dependencies with require('') inside your code. I.e. do something like this:
define(function() {
var $ = require("jquery");
});
This will require one module per file and either define aliases inside config.js or using full path to the modules, but will not push you to define any dependencies upfront.
Also as a bonus, when you use r.js optimizer, which will concatenate your .js file into one giant file, it automatically resolve dependencies and rewrite header for you.
Also minor gotcha I had to deal with - since requirejs literally parse JS code for any require("..") calls, you can not put module name into variable and do require(variable_name) unless this code already loaded in the current context. So try always put actual name into require("...") call.
disclaimer: working on quite large require.js powered app - https://www.myedu.com/ https://www.myedu.com/ - not entire app is converted into require.js, but you can already checkout My Jobs page to get an idea of what is possible - e.g. async loading of various submodules when needed depending on current route.
- graue 13y agoOfftopic: your employer MyEdu constantly spammed me throughout college with emails pretending to be from a university affiliate, when you had just slurped everyone's email from the public contact database. The intent was clearly to deceive and misrepresent the nature of the email. Shame on you for working for a spammy and exploitative business.
- hippich 13y agoI am sorry to hear that. Could you please email details to pavel.karoukin@myedu.com so we could figure out what was going on and possible make it right?