0

To speed up my web application load time, I wish to concatenate all my vendors (3rd party packages) javascript files. For instance, jQuery, Angular, and many bower packages.

Some packages are scoping their "use strict" and some are not. I am worried about concatenating: As far as I understand, If I use a package that isn't written so good, and some other package forced a "use strict" globally, this may cause bugs.

Does a safe way exist to bundle them all together?

Thanks.

Dor Rotman
  • 1,511
  • 1
  • 15
  • 27
  • I'm also concatenating bower and 3rd vendor packages but I'm using gulp, I think is better. – thegio Apr 14 '16 at 08:31

1 Answers1

0

I suggest you the grunt plugin: grunt-contrib-concat

https://github.com/gruntjs/grunt-contrib-concat

The configuration for grunt-contrib-concat goes in the configuration object under the concat key as shown below:

concat: {
  options: {
    // define a string to put between each file in the concatenated output
    separator: ';'
  },
  dist: {
    // the files to concatenate
    src: ['src/**/*.js'],
    // the location of the resulting JS file
    dest: 'dist/<%= pkg.name %>.js'
  }
}

Here you tell the concat task to concatenate all files that exist within src/ and end in .js.

I hope it helps.

thegio
  • 1,233
  • 7
  • 27
  • Thanks. Although this answer is informational, it does not address the question about concatenation safety. – Dor Rotman Apr 17 '16 at 07:41