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.

JavaScript doesn't execute once pre-rendered page is loaded and each page reloads from the server

See original GitHub issue

When I load the pre-rendered pages in my browser, each page I click reloads the page from the server. Also, non of my Vue JavaScript seems to work. For example, I have validation on a form and a submit handler, and none of that code is run.

  plugins: [
   ...
    new PrerenderSPAPlugin({
      // Required - The path to the webpack-outputted app to prerender.
      staticDir: path.join(__dirname, '../dist'),
      // Required - Routes to render.
      routes: [ '/', '/about', '/contact_us' ]
    }),
   ...

That is my config in build/webpack.prod.conf.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14

github_iconTop GitHub Comments

4reactions
srchulocommented, Sep 3, 2018

There are no JS errors in the console.

And wow, data-server-rendered=“true” did the trick. Should this be listed in the prerender-spa-plugin documentation? I found that mentioned here:

https://ssr.vuejs.org/guide/hydration.html

But I wouldn’t have known to use that, especially since that’s in the server side render documentation.

0reactions
eybartacommented, Nov 4, 2018

My JS functions also stopped working after prerendering… data-server-rendered="true" solved my issue… thx!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How Next.Js application does not reload even though they are ...
On client-side navigations Next.js does work like a SPA. It'll only fetch the full HTML from the server on initial page load, from...
Read more >
Puppeteer | Puppeteer
Puppeteer is a Node.js library which provides a high-level API to control ... Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. ......
Read more >
Rendering on the Web
Running page logic and rendering on the server makes it possible to avoid sending lots of JavaScript to the client, which helps achieve...
Read more >
Server-Side Rendering (SSR) - Vue.js
Server -rendered markup doesn't need to wait until all JavaScript has been downloaded and executed to be displayed, so your user will see...
Read more >
Why Efficient Hydration in JavaScript Frameworks is so ...
Most frameworks hydration ready code is larger than their typical client ... More importantly, islands means server rendering each page on ...
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