Christian Fratta
Christian Fratta

Reputation: 294

Does it matter if I include .min. in a script's filename?

Thinking about the neat tricks browsers use to optimize the user experience (see Preconnect, prefetch, prerender), I was wondering if any such obscure magicks are applied to files with the *.min.js filename.

To clarify, provided I have two copies of the same minified file, will browser behaviour change in any way because one is called bananas.min.js instead of bananas.js?

I tried searching for information but I found literally nothing that is relevant (with most results having to do with sourcemaps and the meaning/usefulness of minification), so I assume nothing special happens and it's just a naming convention, but I'd like to make sure.

Upvotes: 1

Views: 1774

Answers (2)

James Thorpe
James Thorpe

Reputation: 32202

I assume nothing special happens and it's just a naming convention

Yes, exactly that.

provided I have two copies of the same minified file, will browser behaviour change in any way because one is called bananas.min.js instead of bananas.js

Not at all.

Names of files generally don't cause any change in behaviour in browsers, instead attributes are used on the elements to control them - for instance on the <script> element you could use async or defer etc.

Upvotes: 3

Julien Deniau
Julien Deniau

Reputation: 5040

The .min.js file is generally just a minified version of the .js.

The minification process should not alter the functionality, but does improve loading speed of the file.

The browser should do the same things.

Upvotes: 0

Related Questions