Removes all unnecessary characters from the code that are not required by the browser to correctly process the resource. This includes white spaces, line break characters, comments, bookmarks etc.
Minified resources behave in exactly the same way as the original. Browsers can immediately handle minified resources without any additional steps.
Note: Minified code is difficult to read (for humans) and is therefore unsuitable for debugging.
Reduces the size of resources by encoding their data. To apply compression, you must also enable minification for resources of the given type.
When a client browser receives a compressed resource, it must first decompress the data. All browsers officially supported by Kentico should be able to correctly decompress files. In cases where the client cannot process compressed data, the system automatically sends the unmodified resource instead.
You can enable or disable code minification and compression globally for all sites in Settings -> System -> Performance, through the settings in the Resources category.
Reducing the size of requested resources saves bandwidth and improves the response time of your website. Minification can decrease the size of a resource by approximately 20–40%, depending on the code of the given object. If compression is also used, resources can be reduced to roughly 30% of their original size.
Note: The reductions only apply to resources stored individually in the file system or database. Inline code inserted into the HTML markup of pages is not affected.
The minification and compression process slightly increases the server CPU load and adds a short delay to resource requests. To counter this issue, the system uses server-side caching for resource files:
- Minification/compression only occurs once when a resource is requested for the first time (the cache stores the result).
- On subsequent client requests, the system provides the transformed version of the resource from the cache.
- The cache stores both compressed and uncompressed versions of resources, so the data is readily available even for clients without compression support.
- You can set the number of minutes for which files are cached through the Cache files (minutes) setting in Settings -> System -> Performance.
Additionally, you can use client‑side browser caching for resources (enabled by default). With client caching, browsers only reload resources from the server if the cached data expires or the content of the resource becomes outdated. See Caching files and resources to learn how to configure the client-side file caching.
Requesting minified resources
You can manually load resources in your code by using the following URL parameters with the handler:
- stylesheetname - used to request a CSS stylesheet from the database. The code name of the requested stylesheet must be entered as the value of the parameter.
<link href="/Kentico/CMSPages/GetResource.ashx?stylesheetname=CorporateSite" type="text/css" rel="stylesheet">
- _transformations, _layouts, _templates, _devicelayouts, _webparts, _webpartlayouts, _containers - used to request the internal stylesheets of the corresponding type of page component. The object ID values of the given components must be entered as the value of the parameter, separated by semicolons (if multiple component stylesheets are requested). See Adding CSS stylesheets to page components.
<link href="/Kentico/CMSPages/GetResource.ashx?_containers=1;14" type="text/css" rel="stylesheet"/>
<link href="/Kentico/CMSPages/GetResource.ashx?_transformations=3511" type="text/css" rel="stylesheet">
- stylesheetfile - used to request static CSS resources from the file system. The relative path of the requested .css file must be entered into the parameter.
<link href="/Kentico/CMSPages/GetResource.ashx?stylesheetfile=/Kentico/App_Themes/Design/OnSiteEdit.css" type="text/css" rel="stylesheet">
Resource requests with minification disabled
Requests in this URL format are always supported, but they do not perform minification or compression of resources.
Enabling compression of page output
You can configure the system to compress the HTML output code of all pages rendered by Kentico.
Note: Output compression requires compliance from client browsers. Browsers that do not support compression always download uncompressed page output.
- Go to Settings -> System -> Performance.
- Check Enable output compression.
- Click Save.
The setting applies globally for all sites in the system.