almond

Most Efficient Multipage RequireJS and Almond setup

此生再无相见时 提交于 2019-11-28 03:02:27
I have multiple pages on a site using RequireJS, and most pages have unique functionality. All of them share a host of common modules (jQuery, Backbone, and more); all of them have their own unique modules, as well. I'm wondering what is the best way to optimize this code using r.js . I see a number of alternatives suggested by different parts of RequireJS's and Almond's documentation and examples -- so I came up with the following list of possibilities I see, and I'm asking which one is most recommended (or if there's another better way): Optimize a single JS file for the whole site , using

How do I export a global variable from Require.js?

不打扰是莪最后的温柔 提交于 2019-11-27 23:10:06
I'm trying to make an external library using Require.js. Thanks to Require.js not compiling single js file correctly and Require.js (almond.js) Timing Off I've figured out how to get everything to "compile" in to a single optimized/built file, and that single file works. There's just one problem: I can't figure out how to set a variable for my library. Let's say I want my library to create window.Foo . I tried using a main.js file with: window.Foo = require([], function() { window.Foo = {someValue: 1}; return {someValue: 2}; }); and a wrapper end fragment of: return require('main'); })); As

Most Efficient Multipage RequireJS and Almond setup

≯℡__Kan透↙ 提交于 2019-11-26 23:54:31
问题 I have multiple pages on a site using RequireJS, and most pages have unique functionality. All of them share a host of common modules (jQuery, Backbone, and more); all of them have their own unique modules, as well. I'm wondering what is the best way to optimize this code using r.js. I see a number of alternatives suggested by different parts of RequireJS's and Almond's documentation and examples -- so I came up with the following list of possibilities I see, and I'm asking which one is most

How do I export a global variable from Require.js?

我的梦境 提交于 2019-11-26 21:19:09
问题 I'm trying to make an external library using Require.js. Thanks to Require.js not compiling single js file correctly and Require.js (almond.js) Timing Off I've figured out how to get everything to "compile" in to a single optimized/built file, and that single file works. There's just one problem: I can't figure out how to set a variable for my library. Let's say I want my library to create window.Foo . I tried using a main.js file with: window.Foo = require([], function() { window.Foo =