Open Closed

JQuery still added dispite using BundleContributor to remove it #819


User avatar
0
edirkzwager created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v4.1.1
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Seperated (Angular): yes
  • Exception message and stack trace: None
  • Steps to reproduce the issue: In order to use Telerik we have to remove the jquery and add it at the top of the page. This works al perfectly. We have found that jquery is still present/added at two screens of ABP itself namely Users and Organization Units. How to reproduce : Create a bundle contributor to remove JQuery like this :
	public class RemoveJqueryScriptContributor : BundleContributor
	{
		public override void ConfigureBundle(BundleConfigurationContext context)
		{
			context.Files.RemoveAll(x => x.StartsWith("/libs/jquery/jquery.js", StringComparison.InvariantCultureIgnoreCase));
		}
	}
Use this contributor in the webmodule like this :
			Configure<AbpBundlingOptions>(options =>
			{
				options
					.ScriptBundles
					.Configure("Lepton.Global", bundle =>
					{
						bundle.AddContributors(typeof(Support.RemoveJqueryScriptContributor));
					});
			});

Start the application and go to the Identity/Users screen and view the source. There you will find that the jquery.js is still there. However, if you go to the Identity/Roles you will find jquery.js is not there. We have noticed that both screens ( Users and Organization Units) also include jstree.js. I To me it seems the reported problem is somehow related to the use of jstree.js.

source of Users (incorrect) :

source of Organization Units (incorrect):

source of Roles (corrcect) :

Because we added jquery at the top of the page (wich works) the second added jquery.js by ABP itself will give a problem.


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Yes, the JsTreeScriptContributor depends on jquery. try:

    options
        .ScriptBundles
        .Configure(typeof(Volo.Abp.Identity.Web.Pages.Identity.Users.IndexModel).FullName, bundle =>
        {
    
            bundle.AddContributors(typeof(RemoveJqueryScriptContributor));
        });
    
    options
        .ScriptBundles
        .Configure(typeof(Volo.Abp.Identity.Web.Pages.Identity.OrganizationUnits.IndexModel).FullName, bundle =>
        {
    
            bundle.AddContributors(typeof(RemoveJqueryScriptContributor));
        });
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    See https://github.com/abpframework/abp/pull/7333, You can use the ConfigureAll method in v4.3

  • User Avatar
    0
    edirkzwager created

    Thanks you liangshiwei. Your suggestion solved the issue. Your proposal for the 4.3 version looks good.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11