Bundle and minify all js css files3/21/2024 Next, you need to add the tags into your layout, like this: To ensure that Umbraco uses this new config file, you need to register it within OnApplicationStarted method in global.ascx, like this: From my experience, if you use the min versions, you'll likely get JS errors, as it tries to minify a minified file :P Register The Config Within Your Global.ascx Also, as we're minimising the CSS and JS, you shouldn't need to explicitly use the min versions of any libraries you use. It's best to keep with the 'bundle' prefix if you are following this tutorial. As we using Umbraco, we need to create a separate rule for Umbraco to ignore some default path. Each bundle route has to be unique though. In my example, this route is ~/bundles/css. When you create a Bundle, you give it a route. You can use the StyleBundle to process CSS and you can use ScriptBundle to process JS. The code above is hopefully pretty self-explanatory. An example of the nfig I use on this site is shown below: This class is where we'll add the code to minify the scripts and styles. Next, you need to create a new class and call it BundleConfig.cs. You can do this by typing in the following in the package manager console. As I'm a C# guy, you can guess the way I'm going.įirst, you'll need to install the NuGet package. You can use more frontend focused bundling tools like grunt/gulp, however, there's also a C# way. There are a few ways to get bundling and minification to work within Umbraco. How To Use ASP.NET Bundling and Minifications in Umbraco If you want to learn how to do that, then read on. As we're using Umbraco however, we have to do a few more tweaks to make the out of the box bundling work. NET, the framework comes with a reasonable CSS/JS bundling solution out-of-the-box. If you are loading multiple CSS files or Javascript files within your page, GT Metrix will penalize your page score. To figure out how optimized your website is you can use tools such as GT Metrix, or Y Slow to run a page performance test to see where the bottlenecks within your pages are. Having a well-optimized website should be the aim for anyone reading this.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |