3

I'm looking into using Bower with my project (more specifically, django-bower), and I was curious if bower has the ability to combine multiple javascript files into one file when pushing to production.

In other words it would take:

  • jquery.min.js
  • angular.min.js
  • something_else.js
  • another_thing.js

and produce one file that the user loads: everything.js

In reality we have upwards of 20-30 js files, which is why this would be incredibly helpful.

Leah Sapan
  • 3,621
  • 7
  • 33
  • 57

2 Answers2

4

Bower is a package manager. I think what you're looking for is Grunt.

See how to minify multiple js files using grunt.

Community
  • 1
  • 1
Dziad Borowy
  • 12,368
  • 4
  • 41
  • 53
2

Use Browserify. It takes your Node requires and compiles them into a single JS file that can be included in your HTML. Ex main.js:

var JQuery = require('jquery');
var Angular = require('Angular');
require('./something_else');
require('./another_thing');

Browserify your dependency chain...

browserify main.js > compiled.js

Include in your HTML

<html>
  <head>
    <script type="text/javascript" src="compiled.js"></script>
  </head>
</html>
Preston S
  • 2,751
  • 24
  • 37