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.

2 Answers 2

4

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

See how to minify multiple js files using grunt.

Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.