Open Closed

How to remove a JavaScript or CSS file from the bundle in MVC? #184


User avatar
0
alper created
Support Team Director

How do I remove the jquery.js from the bundle?


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    There are standard bundles come from the framework itself. These are CSS and JavaScript bundles. You can get list of these files and remove/add. Open BookStoreWebModule.cs In ConfigureServices() method, add the below code

       Configure<AbpBundlingOptions>(options =>
                {
                    options
                        .ScriptBundles
                        .Configure(StandardBundles.Scripts.Global, bundle => {
                            bundle.AddContributors(typeof(RemoveJqueryScriptContributor));
                        });
                });
    

    And add this class,

    public class RemoveJqueryScriptContributor : BundleContributor
            {
                public override void ConfigureBundle(BundleConfigurationContext context)
                {
                    var jquery = context.Files.FirstOrDefault(x => x.EndsWith("jquery.js", StringComparison.InvariantCultureIgnoreCase));
                    if (jquery != null)
                    {
                        context.Files.Remove(jquery);
                    }
                }
            }
    

    This code removes jquery.js from the standard global scripts bundle.

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.2.0-preview. Updated on January 09, 2026, 07:22
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.