0

After upgrading from Nuxt 2.14.12 to Nuxt Bridge, our TogetherJS implementation is not working now. From what I understand TogetherJS is not well maintained anymore but I figured it would at least work in our Vue app.

We're importing the script tag in nuxt.config.js after jquery and bootstrap. And also including a separate together-js-config file

script: [
  {
    src: "https://code.jquery.com/jquery-3.3.1.min.js",
    type: "text/javascript"
  },
  {
    src:
      "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js",
    type: "text/javascript"
  },
  {
    src:
      "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js",
    type: "text/javascript"
  },
  {
    src: "js/together-js-config.js",
  },
  {
    src: "https://togetherjs.com/togetherjs-min.js",
    //  body: true
  }
],

The error that's happening is just "TogetherJS is not defined" when trying to check if TogetherJS is running in the mounted lifestyle hook

  if (TogetherJS.running) {
    TogetherJS();
  }

Does anyone have any suggestions here? Thanks!

kissu
  • 40,416
  • 14
  • 65
  • 133
  • You should not really import things via a CDN + you don't really need jQuery. The project is indeed not that well maintained (March 2020). Maybe try to import that one as a module locally into a component and see what is inside. Maybe it needs to be transpiled? Feel also free to see if you can repro it in Nuxt2 or Nuxt3. Lastly, maybe give a try to that one: https://github.com/jsfiddle/togetherjs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc – kissu Sep 02 '22 at 18:14
  • @kissu Unfortunately this project already has a lot of jQuery usage in many components so I don't really have the option to not use it. I haven't figured out why yet but I can't get jQuery to work now either. Nuxt Bridge seemed to update jquery, bootstrap and even my vue version so I'm lost as to where the disconnect really is. Thank you for your response. – Christine Treacy Sep 02 '22 at 18:29
  • Don't think that you will be able to properly code with jQuery + some updates down the road. Remove jQuery slowly if you don't want a lot of issues down the road. Also, performance...and it's not state-based. As of the actual issue, try to make a [repro] in a brand new Nuxt2/Nuxt3 project to see if you can replicate the issue. – kissu Sep 02 '22 at 18:32

0 Answers0