RequireJS: Set path to ‘ignore’ Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of RequireJS: Set path to ‘ignore’ without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m using a third-party library (through bower) that declares a dependency that I do not want (it’s just styling). Is it possible to set that dependency to ‘ignore,’ or some such value?


define(['jquery','dep_i_dont_want'], function(){...});

In require config:

paths: {
    'jquery': 'path/to/jquery',
    'dep_i_dont_want': 'ignore'

I would just require to look up ‘dep_i_dont_want’, see that it is ignored, and move on without including it or failing. Is this possible? I do not want to edit the third-party JS file.

For context, it doesn’t seem that this is possible in the ‘paths’ object: none of undefined, null, ”, ‘ignore’, ‘blank’, etc. seem to work.

I suppose I could just point it to a dummy module, but that feels like cheating.


I suppose I could just point it to a dummy module, but that feels like cheating.

Yes, this is what you have to do. There is no way to tell RequireJS “ignore this module”. (There’s the empty: scheme that you can give to r.js for modules loaded from CDNs but that’s just for r.js‘ use during optimization.)

What you can do rather than setting a path to some sort of empty module is add this before your call to require.config:


This will define the module in such a way that if it is required somewhere, its value will be undefined.

We are here to answer your question about RequireJS: Set path to ‘ignore’ - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji