RequireJS - Optimizer

Cary Landholt · 23K views · 2012 · 14:51

Open on YouTube

Web developmentTesting, debugging & developer toolstutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a hands-on walkthrough of setting up the RequireJS optimizer build file when asking about or answering optimizer configuration problems.

Recommended by 1 people across 1 different months, 2013 to 2015.

What it is

A 15-minute screencast by Cary Landholt that walks through the RequireJS Optimizer (r.js), showing how to set up a build file to concatenate and minify AMD modules. It comes with sample source files on GitHub and was updated for newer RequireJS releases.

What people said

Recommends Jason · 2015-02 · Stack Overflow · on “RequireJS Optimizer - Cannot find function defineProperty”

I'm trying to concatenate my js files using the requirejs optimizer. I'm basically following this tut: [this video] This is in my build.js: ({ baseUrl: "../", mainConfigFile: '../main.js', name: '../main', out: '../test.js', paths: { 'jquery': [ '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min', // Fallback 'libraries/jquery-1.11.1.min' ], 'jquery-ui': [ '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min', // Fallback 'libraries/jquery.ui.min' ], 'jquery.browser': 'libraries/jquery.browser.min', 'jquery.mousewheel': 'libraries/jquery.mousewheel.min', 'modernizr': 'libraries/modernizr.min', 'bootstrap-tooltip': 'libraries/bootstrap-tooltip', 'parsley': 'libraries/parsley.min'

Cites dtrenz · 2013-08 · Stack Overflow · on “How can i use the RequireJS optimizer to optimize my app to not use RequireJS anymore?”

Are you trying to load the file in the script tag w/o using data-main + require.js? OR, are you trying to render the file so that RequireJS is no longer used at all? I suspect it's the latter, which is not possible. If the former, that is achieved by bundling Require in via a build file option: [this video]

Cites Malcr001 · 2013-10 · Stack Overflow · on “Requirejs optimiser - Create minified groupings of scripts for sections of the site”

I'm using the requirejs optimiser and I have a lot of JavaScript files for this webapp. I would like to create separate minified scripts which group scripts for certain sections of the site. My question is: how do I create minified groups of scripts and how I prevent script libraries for example JQuery from being added into these module groups which already exist in the scripts.min.js core script? ({ baseUrl: '../static/js', mainConfigFile: '../static/js/main.js', name: 'main', out: '../static/js/scripts.min.js', paths: { requireLib: 'vendor/require/require.min' }, include: ['requireLib', '_core'] }) The current setup above adds all non nested requires plus all the scripts inside _core modul

Cites Malcr001 · 2013-10 · Stack Overflow · on “Requirejs optimiser - Include nested dependencies for certain files and folders”

I'm using the RequireJS optimiser to minify and concatenate my code. At the moment r.js doesn't minify a lot of my scripts because of the nested dependencies. I want to include nested dependencies for: All dependencies inside: 'js/services' All nested dependencies for a list of specific JavaScript files Note: I do realise that there is the option findNestedDependencies: true but this looks for absolutely every dependency across all JavaScript files in the app where as I only want to do this for certain JavaScript files and folders as I have a set of files which are always used on every page/view. My current build file looks like: ({ baseUrl: '../static/js', mainConfigFile: '../static/js/main