icon Bundling & Minification
Created by Orckestra

How to bundle and minify scripts and styles on your website

After the package installation, you don't have to provide any specific actions, everything is ready for bundling and minification.

    Migration from the Bundling & Minification package of the version <2.0

    Bundling & Minification packages of earlier versions used a function Composite.Web.BundlingAndMinification, inside of which content to be processed was included. But it is not needed anymore. So with the Bundling & Minification package of version 2.0 or higher, you must remove this function usage from your pages.

    General processing logic

    Please note that:

    1. Bundling and minification work for all scripts and styles except inline ones or files from external web sites.
    2. The link to the resulting scripts bundle is inserted at the end of <body>.
    3. The link to the resulting styles bundle is inserted at the end of <head>.

    Bundling and minification customization

    Note. If you are logged into the CMS Console or a web site uses a debug mode, the optimization is disabled and you deal with the original files. However, the visitors on your website will get the optimized pages unless they are logged in, too.

    To disable or enable scripts and/or styles optimization:

    1. Open the Web.config file in the root directory of a web site;
    2. Locate to the configuration/AppSettings path;
    3. Find the keyOrckestra.Web.BundlingAndMinification.BundleAndMinifyStyles to manage styles or Orckestra.Web.BundlingAndMinification.BundleAndMinifyScripts to manage scripts.
    4. Set up true to turn on or false to turn the feature off.
    5. Save the changes.

    To exclude specific style or script of your HTML page from the bundling and minification process, add to such element c1-not-bundleminify attribute with "true" value:


      Bundle caching

      Bundles set the HTTP Expires Header one year from when the bundle is created.

      If any file (JS, CSS) in the bundle changes, the ASP.NET optimization framework will generate a new token, guaranteeing that browser requests for the bundle will get the latest bundle.