amd

JavaScript的模块化之AMD&CMD规范

拥有回忆 提交于 2020-01-04 00:47:36
前端开发常常会遇到的问题:   1.恼人的命名冲突;   2.繁琐的文件依赖; 模块化开发的优势:   1.解决命名冲突和依赖管理;   2.模块的版本管理;   3.提高代码的可维护性;   4.前端性能优化; JavaScript本身不具备模块化的功能,开发人员为了更好的开发,需要人为的制定一套规范标准,约定一套固定的写法来实现JavaScript模块化功能。 一个模块化系统所必须的能力:  定义封装的模块  定义新模块对其他模块的依赖  可对其他模块的引入支持 AMD&CMD AMD AMD(Asynchronous Module Definition)异步模块定义: 是 RequireJS 在推广过程中对模块定义的规范化产出。 requireJS主要解决两个问题 多个js文件可能有依赖关系,被依赖的文件需要早于依赖它的文件加载到浏览器 js加载的时候浏览器会停止页面渲染,加载文件越多,页面失去响应时间越长 requireJS定义了一个函数 define,它是全局变量,用来定义模块 define(id?, dependencies?, factory); id:可选参数,用来定义模块的标识,如果没有提供该参数,脚本文件名(去掉拓展名) dependencies:是一个当前模块依赖的模块名称数组 factory:工厂方法,模块初始化要执行的函数或对象。如果为函数

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

RequireJS Optimization

微笑、不失礼 提交于 2020-01-02 20:29:10
问题 I`m using r.js to optimize my app, as i saw in several samples, i used build.json configuration file to config my optimization options. The problem is that when i set reference to the output javascript file after optimization I`m getting the following error in the browser: Uncaught ReferenceError: define is not defined main-built.js:14735 Looks like, all my app modules are exists but RequireJs is missing. This is my build.json configuration file: { "baseUrl": "../", "name": "src/modules/main"

How to find if the chained asynchronous scripts has been loaded?

时光总嘲笑我的痴心妄想 提交于 2020-01-02 10:20:16
问题 Here's the scenario. I am doing a $.getScript() function call to get a script in my javascript file. The script that I'm downloading from the $.getScript() tries to download some other scripts that it's dependent on. In my script I'm using done() to check if the script loaded completely or not. And if it did, then I try calling the function that's not on the script that I just loaded form $.getScript but the script that was loaded in it. It's getting confusing so let me demonstrate with some

Do Intel and AMD processor have the same assembler?

有些话、适合烂在心里 提交于 2019-12-31 08:29:53
问题 The C language was used to write UNIX to achieve portability -- the same C language program compiled using different compilers produces different machine instructions. How come Windows OS is able to run on both Intel and AMD processors? 回答1: AMD and Intel processors(*) have a large set of instructions in common, so it is possible for a compiler or assembler to write binary code which runs "the same" on both. However, different processor families even from one manufacturer have their own sets

Requirejs why and when to use shim config

≡放荡痞女 提交于 2019-12-27 18:21:14
问题 I read the requirejs document from here API requirejs.config({ shim: { 'backbone': { //These script dependencies should be loaded before loading //backbone.js deps: ['underscore', 'jquery'], //Once loaded, use the global 'Backbone' as the //module value. exports: 'Backbone' }, 'underscore': { exports: '_' }, 'foo': { deps: ['bar'], exports: 'Foo', init: function (bar) { //Using a function allows you to call noConflict for //libraries that support it, and do other cleanup. //However, plugins

Requirejs why and when to use shim config

最后都变了- 提交于 2019-12-27 18:21:06
问题 I read the requirejs document from here API requirejs.config({ shim: { 'backbone': { //These script dependencies should be loaded before loading //backbone.js deps: ['underscore', 'jquery'], //Once loaded, use the global 'Backbone' as the //module value. exports: 'Backbone' }, 'underscore': { exports: '_' }, 'foo': { deps: ['bar'], exports: 'Foo', init: function (bar) { //Using a function allows you to call noConflict for //libraries that support it, and do other cleanup. //However, plugins

电脑的32位与64位是指的什么

无人久伴 提交于 2019-12-27 05:49:46
64 位势不可挡 从某种意义上讲,处理器的发展直接影响着整个IT行业的发展水平,电脑核心从16位到32的转变对IT行业产生的巨大影响就是一个强有力证明。从386、486直到奔腾系列的CPU都是32位,大多数情况32位计算已经能满足现阶段人们的需要。然而随着互联网等技术的发展,对内存的需求越来越大,比如大型服务器,每秒钟处理的数据量就超过2GB,32位就难以满足需求了。 32位的风云十年 在信息技术领域,“位数”是衡量计算机性能的重要标准之一。位数在很大程度上决定着计算机的内存最大容量、文件的最大长度、数据在计算机内部的传输速度、处理速度和精度等性能指标。在近十年的时间里,X86-32位平台由于其性价比高,获得广泛应用。 按照以前的习惯,我们把基于80X86的CPU架构称作X86结构,这是Intel公司在1978年发布其第一块16位的CPU(5MHz 8086)时开发的,1981年IBM推出的第一台PC中使用的也是X86指令,同时电脑中为提高浮点数据处理能力而加的X87芯片系列数学协处理器则使用X87指令,后来将X86指令集和X87指令集统称为X86指令集。为了保证计算机能够继续运行以往开发的各类应用程序以保护和继续软件资源,后续的CPU(包括大多数第三方处理器厂商)继续使用X86指令集,采用这种指令集的CPU系统被称作X86架构。 64位异军突起

AMD - Building library example

北城余情 提交于 2019-12-25 10:29:47
问题 It was suggested that I read on AMD and maybe rethink my library setup. For the moment I've coded all of it the IIFE way, hiding all the small components from the global scope . But when I saw how easy it is to just define() things in AMD , I wanted to try it out! But I ran into a couple of problems and I can't seem to understand where it starts and how things are loaded in . Now, be aware that I've read a lot on the subject and I searched for answers, but I think it's more a misconception on