# Adding plugins post initial load

**URL:** <https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045>\
**Category:** Framework Knowledge\
**Created:** [November 4, 2019, 6:12pm UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045 "2019-11-04T18:12:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![elitemike](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitemike/32/690_2.png) [@elitemike](https://discourse.aurelia.io/u/elitemike)\
**Post date:** [November 4, 2019, 6:12pm UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/1 "2019-11-04T18:12:18Z")

</div>

I have a case where I need to add my plugins post initial load. The way my team implemented OIDC has us doing a lot of unnecessary plugin loading when the site will be simply redirected to the login page. It is only after a user is available from OIDC when I want to load the rest of the plugins.

I have tried to add the plugins by instantiating a new FrameworkConfiguration(this.aurelia) where this.aurelia is injected at the constructor. I add the plugins then call config.apply ();

this does not work. I get the this config instance has already been applied. To load more global resources, create a new FrameworkConfiguration instance.

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [November 4, 2019, 9:21pm UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/2 "2019-11-04T21:21:15Z")

</div>

Can you clarify if you are injecting `Aurelia`, or are you injecting something else?

---

<div class="post-metadata">

**Author:** ![elitemike](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitemike/32/690_2.png) [@elitemike](https://discourse.aurelia.io/u/elitemike)\
**Post date:** [November 4, 2019, 11:59pm UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/3 "2019-11-04T23:59:19Z")

</div>

The class that I am trying new new up the FrameworkConfiguration has Aurelia being injected into the constructor.

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [November 5, 2019, 12:15am UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/4 "2019-11-05T00:15:25Z")

</div>

Can you give some pseudo code? From what i understand, simply the follow could already do:

```auto
export class MyEl {
  static inject = [Aurelia]

  constructor(aurelia) {
    const config = new FrameworkConfiguration(aurelia);
    config.use.....
    config.apply();
  }
}

```

---

<div class="post-metadata">

**Author:** ![elitemike](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitemike/32/690_2.png) [@elitemike](https://discourse.aurelia.io/u/elitemike)\
**Post date:** [November 5, 2019, 11:51am UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/5 "2019-11-05T11:51:37Z")

</div>

That is effectively what I’m doing, except I’m using autoinject with typescript and the new config occurs in a function that I call when needed.

---

<div class="post-metadata">

**Author:** ![elitemike](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitemike/32/690_2.png) [@elitemike](https://discourse.aurelia.io/u/elitemike)\
**Post date:** [November 7, 2019, 10:54pm UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/6 "2019-11-07T22:54:51Z")

</div>

Are there any known issues with this? It’s another poorly documented feature.

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [November 8, 2019, 3:23am UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/7 "2019-11-08T03:23:52Z")

</div>

There shouldnt be any. Though its an async process, so best done in router viewport componr ts, during activate/configureRouter cycle. And probably need to make sure its applied only once, regardless how many times a component is activated. Sorry aboit the doc though, could you help with that 😊

---

<div class="post-metadata">

**Author:** ![elitemike](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/elitemike/32/690_2.png) [@elitemike](https://discourse.aurelia.io/u/elitemike)\
**Post date:** [November 8, 2019, 1:44pm UTC](https://discourse.aurelia.io/t/adding-plugins-post-initial-load/3045/8 "2019-11-08T13:44:34Z")

</div>

I’m going to have to make a simple test application.

I’m not relying on component life cycle, I want to only load these plugins if some some condition is met and the loading occurs in a service class.
