I am basing a website on an old tutorial, which uses 3 external js files. I am not able to recreate this using nuxtjs.
First, I tried to include the js files before the tag.
nuxt.config.js
head: {
script: [
{ src: 'js/imagesloaded.pkgd.min.js', type: 'text/javascript', body: true, defer: true },
{ src: 'js/TweenMax.min.js', type: 'text/javascript', body: true, defer: true },
{ src: 'js/demo.js', type: 'text/javascript', body: true, defer: true }
]
},
This works on initial page load. However, as soon as I change the page, the js files are ignored.
After some research, I tried to include the files as a plugin, to avoid ssr.
nuxt.config.js
plugins: [
{ src: "plugins/imagesloaded.pkgd.min.js", mode: 'client' },
{ src: "plugins/TweenMax.min.js", mode: 'client' },
{ src: "plugins/demo.js", mode: 'client' }
],
This gave me multiple error messages (amongst other things: 'Cannot read property addEventListener of null).
This is a very small project with a lot of time pressure, so any kind of help would be highly appreciated!
Update: