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.

Option not to load on server

See original GitHub issue

🚀 Feature Proposal

An option called e.g. noSsr to prevent a loadable component being rendered to HTML on the server.

If option is set, the fallback will be rendered on the server and no chunk sent to ChunkExtractor. The client will then initially render the fallback and async load the component (same as if you weren’t using SSR at all).

Motivation

Often it’s useful to be able to server render only parts of the app, and leave completing the render to the client. This allows:

  • Server render critical parts of the page only
  • Reduce size of code client downloads before app is hydrated
  • Reduce time to hydration on client

Example use cases:

  • Server render only what’s critical for SEO
  • Server render only content that’s “above the fold”
  • Leave downloading of heavy components including large libraries to after hydration, so e.g. interactive menus requiring React at top of page start work faster without waiting for download of a mapping component lower down the page

Example

const OtherComponent = loadable(
  () => import('./OtherComponent'),
  { noSsr: true }
);

On server, this component would just render the fallback.

Pitch

In my opinion, this feature is pretty key to striking a nice balance between the pros and cons of SSR.

This kind of approach is likely to be easier with React’s forthcoming async renderer, so it’d be great to allow people to start working in this way before that drops.

As a bonus, I’m happy to implement it myself, and I don’t think it’d be very difficult!

If I worked up a PR, would you be likely to accept it?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
overlookmotelcommented, Jan 12, 2019

OK great. I’ve started work on this and it seems pretty simple, but still need to write tests. I’ll make a PR in a few weeks time.

0reactions
overlookmotelcommented, Feb 6, 2019

Hi @neoziro. Thanks for implementing this. I was working on it but been delayed by other work. Great that you’ve gone and done it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Option not to load on server · Issue #195 - GitHub
An option called e.g. noSsr to prevent a loadable component being rendered to HTML on the server. If option is set, the fallback...
Read more >
"Cannot connect the computer to the server" error message ...
Cannot connect the computer to the server because either another software installation is in progress or, the computer has a restart pending.
Read more >
Why is an OPTIONS request sent and can I disable it?
Currently, I get the server to ignore any OPTIONS requests. Now my question is what's good to send an OPTIONS request to double...
Read more >
How to Fix Web Pages That Won't Load - Online Tech Tips
Select Internet Protocol Version 4 (TCP/IPv4) and choose Properties. · Turn on the Use the following DNS server addresses option.
Read more >
Users are not able to select the "Allow server to automatically ...
before doing the following: (1) Go to 'Tools->Internet Options->Security'. ... zone the Cognos portal falls into. ... to the 'Trusted sites' zone. ( ......
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