0

I'm brand new to Gulp and I was able to create a site.min.js file, which as I understand is the minified versions of my JavaScript files.

How do I take advantage of that?

I'm not sure if I'm on the right track, but should my index.html also be getting modified to only load the new min.js file?

1 Answer 1

2

When you minify a file, the result is a completely different file. You need to link it in your page in order to use it.

<script src="site.min.js"></script> 

The production version of your index.html file should only link to the minified version and any non-minified version should be removed.

There are gulp plugins which help with this.

They all offer a similar feature where you can specify blocks within HTML comments that will be replaced by the minified version.

<!-- build:js --> <script src="website-module.js"></script> <script src="core.js"></script> <!-- endbuild --> 

With the right options within your gulp task, it would become:

<script src="site.min.js"></script> 
Sign up to request clarification or add additional context in comments.

1 Comment

Got it, I'm a bit surprised that there's dozens of minification and concat examples readily available, but without actually being able to link to the resulting file, all useless, kind of felt like I was missing something. Thanks for your help!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.