question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JS Isn’t Firing

See original GitHub issue

Hi Chris!

Thanks for the plugin and the demos!

I’ve got the build running properly, and the static pages are rendered, but no JS seems to be loading. I have a few @clicks and @submits that aren’t firing when clicked. Is there another step when you have some JS that allows the user to interact with the page?

in main.js

/* eslint-disable no-new */
let root = new Vue({
    router,
    store,
    render: h => h(App)
})

document.addEventListener('DOMContentLoaded', function () {
    root.$mount('#app')
})

the other configs are set up like the example in the Vue Spa repo.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:55 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
Hyracommented, Feb 19, 2017

Same here, building hangs forever when using the captureAfterDocumentEvent

I tried moving the event from beforeMount to created, but neither seems to work.

3reactions
andrewbiang888commented, Mar 9, 2018

I was having a similar problem, but I’m not using webpack-simple.

If you are NOT using webpack-simple (i.e. you have a build/webpack.prod.conf.js file), this should work: https://alligator.io/vuejs/vue-prerender-prerenderer/

Basically, you can use the NEXT version of prerender-spa-plugin and enjoy the renderer option.

NOTE: “SPA” is all caps in this: const PrerenderSPAPlugin = require(‘prerender-spa-plugin’)

BUT YOU PROBABLY NEED TO CHANGE

new PrerenderSPAPlugin({
      staticDir: __dirname,                     // LOOK AT THIS. LOOK AT THIS. LOOK AT THIS
      routes: ['/', '/about'], // List of routes to prerender.
      renderer: new PuppeteerRenderer({        //Yes, checkout the renderer option. It is oh so sweet.
        renderAfterElementExists: '#app'
        // Wait to render until a specified event is fired on the document.
        // renderAfterDocumentEvent: 'renderIt'
      })

TO:

new PrerenderSPAPlugin({
      staticDir: path.resolve(__dirname, '../dist'),                      // CHANGE THIS!!!!!!!!!!!!!!!!
      routes: ['/', '/about'], // List of routes to prerender.
      renderer: new PuppeteerRenderer({
        renderAfterElementExists: '#app'
        // Wait to render until a specified event is fired on the document.
        // renderAfterDocumentEvent: 'renderIt'
      })
    })

This worked for me. I hope this eases your pain. The next version of this plugin looks good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why my javascript isn't working? - Stack Overflow
js file in the beginning in the head tag, javascript is not working. Why? All my javascript do, is counting symbols. $('#field1').keyup(function ...
Read more >
Why won't my code work!? - The Beginner's Guide to Fixing ...
If your JavaScript code isn't working, use this handy checklist to find (and fix) the bugs.
Read more >
Why is JavaScript not working with my HTML? - Quora
The most possible reason is browser cache. Refresh your html by Ctrl+F5 (this will clear the cache and re-read the linked files). Also...
Read more >
Handling Events :: Eloquent JavaScript
There are specific event types fired by touch interaction. When a finger starts touching the screen, you get a "touchstart" event. When it...
Read more >
Handling common JavaScript problems - MDN Web Docs
... getting modern JavaScript features working in older browsers, and more. ... if it isn't, you could then run code to load a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found