---
description: https://www.tutorialspoint.com/requirejs/requirejs_optimizer.htm
---

# RequireJS - Optimizer (ok)

Source: [https://github.com/CaryLandholt/Tutorial-RequireJS-Optimizer](https://github.com/CaryLandholt/Tutorial-RequireJS-Optimizer)

{% file src="https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MTAMokPfEPe--PWEeFR%2F-MTAN25cEsvTWdENrLJa%2FTutorial-RequireJS-Optimizer-master.zip?alt=media&token=abaca6de-e782-4952-8e66-05c6e7206a3b" %}

{% embed url="https://www.youtube.com/watch?v=m6VNhqKDM4E" %}

#### Bài toán 1: concatenated-modules.build.js

C:\Users\Administrator\Desktop\Tutorial-RequireJS-Optimizer-master\Scripts\main.js

```
/*global require*/
require.config({
	paths: {
		//core
		'doc': 'core/doc',
		'document': 'core/document',
		'publish': 'core/publish',
		'pubsub': 'core/pubsub',
		'subscribe': 'core/subscribe',
		'unsubscribe': 'core/unsubscribe',
		'window': 'core/window',
		// events
		'dirty': 'events/dirty',
		'textchange': 'events/textchange',
		// libs
		'jquery': 'libs/jquery'
	}
});
require(['app']);
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MTA5bB7AuOGVrYIcUVC%2F-MTAJj9_0tTbNg9QwZfb%2FScreenshot_1.jpg?alt=media\&token=3a434dd3-4bd4-48a4-9397-7e35cf1206ab)

C:\Users\Administrator\Desktop\Tutorial-RequireJS-Optimizer-master\build\concatenated-modules.build.js

```
({
	baseUrl: '../Scripts',
	mainConfigFile: '../Scripts/main.js',
	name: '../Scripts/main',
	out: '../Scripts/concatenated-modules.js',
	optimize: 'none'
})
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MTA5bB7AuOGVrYIcUVC%2F-MTAK7Y6yN3p6nE5_kdJ%2FScreenshot_2.jpg?alt=media\&token=82ee3367-b263-436d-9729-2129dde6b5a5)

C:\Users\Administrator\Desktop\Tutorial-RequireJS-Optimizer-master\build\build.sh

```
java \
-classpath \
js.jar \
org.mozilla.javascript.tools.shell.Main \
r.js \
-o \
concatenated-modules.build.js
```

#### Bài toán 2: concatenated-uglified-modules.build.js

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MTA5bB7AuOGVrYIcUVC%2F-MTAMd3pWpND8lkOHi7p%2FScreenshot_6.jpg?alt=media\&token=0674b9a8-7790-4a38-80f0-1c6d0b90a313)

C:\Users\Administrator\Desktop\Tutorial-RequireJS-Optimizer-master\build\build.sh

```
java \
-classpath \
js.jar \
org.mozilla.javascript.tools.shell.Main \
r.js \
-o \
concatenated-uglified-modules.build.js
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MTA5bB7AuOGVrYIcUVC%2F-MTALA8SOV6XYrPT5TBq%2FScreenshot_3.jpg?alt=media\&token=7dac8f44-58c1-4c4e-a2c1-b2fc809e0fd9)

C:\Users\Administrator\Desktop\Tutorial-RequireJS-Optimizer-master\build\concatenated-uglified-modules.build.js

```
({
	baseUrl: '../Scripts',
	mainConfigFile: '../Scripts/main.js',
	name: '../Scripts/main',
	out: '../Scripts/concatenated-uglified-modules.js'
})
```

#### Bài toán 3: concatenated-uglified-noLicenseComments-modules.build.js

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MTA5bB7AuOGVrYIcUVC%2F-MTAMDgKzkhjRqpfDwGO%2FScreenshot_4.jpg?alt=media\&token=00b220f5-c17f-42dc-a798-70d85dcc8a6e)

C:\Users\Administrator\Desktop\Tutorial-RequireJS-Optimizer-master\build\build.sh

```
java \
-classpath \
js.jar \
org.mozilla.javascript.tools.shell.Main \
r.js \
-o \
concatenated-uglified-noLicenseComments-modules.build.js
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MTA5bB7AuOGVrYIcUVC%2F-MTAMLP9mMuxNrOzZwUs%2FScreenshot_5.jpg?alt=media\&token=ea0509b1-9848-47bc-8040-63d32544a274)
