js-amd

AMD: what is the purpose in javascript context?

*爱你&永不变心* 提交于 2021-01-27 13:15:31
问题 Regarding AMD (Asynchronous Module Definition ) I read the phase like this: The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order" and something that was easy to use directly in the browser. What is the the purpose in javascript context? Can you make some example? pro et contro of using AMD? 回答1: Long before JavaScript gained a native module system, the only way to put scripts

How does AMD (specifically RequireJs) handle dependancies across multiple modules

你说的曾经没有我的故事 提交于 2020-01-12 14:30:08
问题 I have my main initialization script which calls require() and one of the dependencies is a utilities framework, but some of the other modules that I'm specifying via require() also themselves have defined this framework as a dependency. For example (init.js): require(['module-a', 'module-b', 'module-c'], function(a, b, c){ // where module-c is the framework }); And then in 'module-a' I have: define(['module-c'], function(c){ // utilize module-c framework }); So how does AMD/RequireJs handle

How does AMD (specifically RequireJs) handle dependancies across multiple modules

本秂侑毒 提交于 2020-01-12 14:28:39
问题 I have my main initialization script which calls require() and one of the dependencies is a utilities framework, but some of the other modules that I'm specifying via require() also themselves have defined this framework as a dependency. For example (init.js): require(['module-a', 'module-b', 'module-c'], function(a, b, c){ // where module-c is the framework }); And then in 'module-a' I have: define(['module-c'], function(c){ // utilize module-c framework }); So how does AMD/RequireJs handle

Load JavaScript and CSS files in folders in AngularJS

感情迁移 提交于 2020-01-03 13:10:53
问题 I have an AngularJS application and in the future, some developers in other teams will develop modules that will be installed as parts of it. So I defined the folder structure as below. www/ index.html app.js modules/ modulesA/ -- will be copied when module A was installed moduleA.js moduleA.css moduleA.partial.html modulesB/ -- will be copied when module B was installed moduleB.js moduleB.css moduleB.partial.html Now I have a problem. When user installed module A, how to let AngularJS (and

Load JavaScript and CSS files in folders in AngularJS

杀马特。学长 韩版系。学妹 提交于 2020-01-03 13:10:13
问题 I have an AngularJS application and in the future, some developers in other teams will develop modules that will be installed as parts of it. So I defined the folder structure as below. www/ index.html app.js modules/ modulesA/ -- will be copied when module A was installed moduleA.js moduleA.css moduleA.partial.html modulesB/ -- will be copied when module B was installed moduleB.js moduleB.css moduleB.partial.html Now I have a problem. When user installed module A, how to let AngularJS (and

What is an immediately executed factory function in the context of JS module loading?

情到浓时终转凉″ 提交于 2020-01-03 03:09:03
问题 In the Require.js documentation, in the section called Why AMD, the following is asked: How are pieces of JavaScript code defined today? Among other answers is the following: Defined via an immediately executed factory function. I understand (at least I think I do) that a javascript factory function is simply a function that returns a new instance of an object, but I don't understand what this means in the context of this question. Can someone explain this? 回答1: My guess is you are not clear

What is an immediately executed factory function in the context of JS module loading?

馋奶兔 提交于 2020-01-03 03:07:25
问题 In the Require.js documentation, in the section called Why AMD, the following is asked: How are pieces of JavaScript code defined today? Among other answers is the following: Defined via an immediately executed factory function. I understand (at least I think I do) that a javascript factory function is simply a function that returns a new instance of an object, but I don't understand what this means in the context of this question. Can someone explain this? 回答1: My guess is you are not clear

Dojo AMD loader not working in Domino 9.0

戏子无情 提交于 2019-12-25 01:01:57
问题 When I put this on my Form (not XPage): <script src="/xsp/.ibmxspres/dojoroot/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script> calls like this: require(["dojox/validate/web"], function(validate) { validate.isEmailAddress(someAddress); }); fail with error (this error is from Opera 12.15): Unhandled Error: Undefined variable: require I checked with Chrome network panel that dojo.js is loaded and tried also with IE10. If I use: <script src="//ajax.googleapis.com/ajax/libs

jQuery plugin + AMD = how to access functions?

守給你的承諾、 提交于 2019-12-24 21:57:09
问题 I am wrapping up my jQuery plugin in an AMD environment. This is my boilerplate, !function(root, factory) { if (typeof define === 'function' && define.amd) { define(['jquery'], factory); } else { factory(root.jQuery); } }(this, function($) { var defaults = { target: '' }; var myPlugin = function(options) { options = $.extend(true, {}, defaults, options); return options; }; myPlugin.prototype = { init: function(options) { return options; } }; $.fn.myPlugin = myPlugin; }); console.log($.fn

RequireJs optimizer ignore plugin

对着背影说爱祢 提交于 2019-12-23 13:01:10
问题 I would like to ignore the use of a require js plugin when I use the optimizer define(["css!styles.css"]) This always gives me this error Cannot read property 'normalize' of undefined . I've set this options to the require optimizer { paths : { 'css' : 'empty:' } } But it keeps giving me the error. 回答1: I don't know if that is what you want, but you could stub out the css plugin. //Specify modules to stub out in the optimized file. The optimizer will //use the source version of these modules