How does CSS / Javascript work in conjunction with MVC?

I'm a little confused about how MVC handles CSS and Javascript, and I have a few questions.

Whenever I create a default MVC application (5), I see that several CSS and Javascript libraries have already been added with normal and reduced versions.

When I look at the BundleConfig class, I see that regular files are linked together, but mini-types are not.

When are mini versions really used? When I debug a site or even deploy it to a server, I never see that they are used. Is it something I have to change myself, or is there a setting for this?

Also, do you need to keep regular and minified versions of these files in sync, or is that something MVC can do automatically?

thanks

+4
source share
2 answers

Packaging

Linking is a new feature in ASP.NET 4.5 that makes it easy to merge or merge multiple files into a single file. You can create CSS, JavaScript, and other packages. Fewer files means fewer HTTP requests and this can improve front page load performance.

minification

Minimization performs many different code optimizations for scripts or css, for example, removing extra space and comments and reducing variable names to one character.

Your question?

When I look at the BundleConfig class, I see that regular files are merged together, but mini versions are not.

Answer:

bundle.B'cos, , () , . Debug .

?

-? , , , . - , ?

:

Minified version , ( ). . , .

?

, - , - MVC ?

:

. .

:

. , . , .

Bundle vs Minification,

+1

, Debug, . , , .

, ,

BundleTable.EnableOptimizations = true;

BundleConfig. . , , :

#if !DEBUG
     BundleTable.EnableOptimizations = true;
#endif

,

0

Source: https://habr.com/ru/post/1527161/


All Articles