# JS plugins not loading correctly

**URL:** https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105
**Category:** Bug
**Created:** [October 9, 2018, 2:33pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105 "2018-10-09T14:33:28Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![rbrlortie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rbrlortie/32/166740_2.png) [@rbrlortie](https://meta.discourse.org/u/rbrlortie)
#### Post date: [October 9, 2018, 2:33pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/1 "2018-10-09T14:33:28Z")

</div>

Hi,

Since last week or so my discourse is having trouble loading JS plugins.

What is strange is that they are indeed loaded correctly in the Network tab:

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/e/ae20dae2efea4e82e9f15c5174b0270ed00503f5.png)

I am getting errors such as  
`TypeError: e.find(...).not(...).magnificPopup is not a function`

`TypeError: window.Chart is not a constructor`

It seems that stuff getting loaded via `loadScript("/javascripts/jquery.magnific-popup.min.js")` are not loading correctly.

Discourse version: [v2.2.0.beta2 +184](https://github.com/discourse/discourse/compare/b5bdd42838aa5401dedb7bc7d1548c8888d95b5f...tests-passed)

Does anyone have a clue as to why this might happen or steps to debug this? Thanks!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 9, 2018, 4:25pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/2 "2018-10-09T16:25:47Z")

</div>

Do you mean from a customization or plugin, or are you referring to a plain vanilla install?

---

<div class="post-metadata">

### Author: ![rbrlortie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rbrlortie/32/166740_2.png) [@rbrlortie](https://meta.discourse.org/u/rbrlortie)
#### Post date: [October 9, 2018, 5:34pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/3 "2018-10-09T17:34:38Z")

</div>

The front-end should be vanilla except for two script inclusions that aren’t causing errors.

Core features like the `/admin` dashboard charts aren’t displaying.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [October 9, 2018, 5:46pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/4 "2018-10-09T17:46:12Z")

</div>

Is this on your local environment or on a live site? Also, can you confirm that you have the `Chart.min.js` and `jQuery.magnific-popup.min.js` in the `/public/javascripts/` folder?

---

<div class="post-metadata">

### Author: ![rbrlortie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rbrlortie/32/166740_2.png) [@rbrlortie](https://meta.discourse.org/u/rbrlortie)
#### Post date: [October 9, 2018, 5:51pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/5 "2018-10-09T17:51:08Z")

</div>

You can see it live in most posts, e.g. [https://www.robotshop.com/community/forum/t/mini-sumo-at-the-next-ny-makerfair/33003/3](https://www.robotshop.com/community/forum/t/mini-sumo-at-the-next-ny-makerfair/33003/3)

The file is there and you can see from the network tab that it’s loading: [https://www.robotshop.com/community/forum/javascripts/jquery.magnific-popup.min.js](https://www.robotshop.com/community/forum/javascripts/jquery.magnific-popup.min.js)

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [October 9, 2018, 5:56pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/6 "2018-10-09T17:56:20Z")

</div>

Hmm, interesting. There are no images in the topic you linked above, so I don’t see what’s triggering the magnificPopup call.

---

<div class="post-metadata">

### Author: ![rbrlortie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rbrlortie/32/166740_2.png) [@rbrlortie](https://meta.discourse.org/u/rbrlortie)
#### Post date: [October 9, 2018, 6:35pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/7 "2018-10-09T18:35:48Z")

</div>

I am looking at our previous stable environment and it seems that those issue might have started to appear when we moved from: Discourse 2.1.0.beta4 → Discourse 2.2.0.beta2

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [October 10, 2018, 1:09pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/12 "2018-10-10T13:09:40Z")

</div>

Hey @rbrlortie, a recent change to `loadScript` is not working as expected for subfolder installs, but I have identified the issue and submitted a fix.

Thanks for the report, and I will let you know when it’s ready for update!

* * *

PR for reference:

[https://github.com/discourse/discourse/pull/6474](https://github.com/discourse/discourse/pull/6474)

---

<div class="post-metadata">

### Author: ![rbrlortie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rbrlortie/32/166740_2.png) [@rbrlortie](https://meta.discourse.org/u/rbrlortie)
#### Post date: [October 10, 2018, 1:57pm UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/13 "2018-10-10T13:57:24Z")

</div>

Awesome! We are awaiting your go to update our instance. 😀

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [October 11, 2018, 5:58am UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/14 "2018-10-11T05:58:39Z")

</div>

The fix is in `test-passed` 💪 Feel free to update anytime now. Thanks again!

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [October 15, 2018, 10:00am UTC](https://meta.discourse.org/t/js-plugins-not-loading-correctly/99105/17 "2018-10-15T10:00:03Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.
