Title: Javascript include is buggy
Last modified: September 11, 2017

---

# Javascript include is buggy

 *  [gmariani405](https://wordpress.org/support/users/gmariani405/)
 * (@gmariani405)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/javascript-include-is-buggy/)
 * If you have two of your widgets at the same time but displayed on different pages,
   then the JavaScript is NOT included. This breaks the expanding. Since you’re 
   using include_once(), it is including the JavaScript for the first widget which
   is not displayed (or rendered at all). So when the second widget comes around,
   it doesn’t get the JavaScript and breaks. You need to switch from using include_once()
   to include a JavaScript file. That’s not really what it’s for and is a bit of
   a hack. For the time being, I had to edit your plugin to just do include() so
   it would work. But your next update will remove my fix. Please use enqueue_script
   or something more reliable. Thanks

The topic ‘Javascript include is buggy’ is closed to new replies.

 * ![](https://ps.w.org/collapsing-archives/assets/icon-256x256.gif?rev=2550328)
 * [Collapsing Archives](https://wordpress.org/plugins/collapsing-archives/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/collapsing-archives/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/collapsing-archives/)
 * [Active Topics](https://wordpress.org/support/plugin/collapsing-archives/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/collapsing-archives/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/collapsing-archives/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [gmariani405](https://wordpress.org/support/users/gmariani405/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/javascript-include-is-buggy/)
 * Status: not resolved