npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

above-the-fold-only-server-render

v1.1.0

Published

A React component wrapper for optionally skipping SSR.

Downloads

777

Readme

above-the-fold-only-server-render

NPM version Build Status Dependency Status

A React component for optionally skipping server side rendering of components outside above-the-fold (or outside of the viewport). This component helps render your components on the server that are above the fold and the remaining components on the client.

Performance

AboveTheFoldOnlyServerRender helps increase performance both by decreasing the load on renderToString and sending the end user a smaller amount of markup.

The following table outlines a clear performance increase in the example app by skipping server rendering on the Walmart.com Footer component and several other below the fold zones:

| | HTML Size | renderToString Time | | -------- | -------------- | ------------------- | | before | 452 kB | 249 ms | | after | 315 kB | 177 ms | | diff | -137 kB (-30%) | -72 ms (-29%) |

Installation

npm install above-the-fold-only-server-render

Usage

By default, the AboveTheFoldOnlyServerRender component simply returns the child component. You can tell the component to skip server rendering either by passing a prop skip={true} or setting up aboveTheFoldOnlyServerRender in your app context and passing the component a contextKey prop.

You can skip server side rendering by passing a skip prop:

import { AboveTheFoldOnlyServerRender } from "above-the-fold-only-server-render";

const SomeComponent = () => {
  return (
    <AboveTheFoldOnlyServerRender skip={true}>
      <div>This will not be server side rendered.</div>
    </AboveTheFoldOnlyServerRender>
  );
};

You can also skip server side rendering by setting context and passing a contextKey prop:

import { AboveTheFoldOnlyServerRender } from "above-the-fold-only-server-render";

const SomeComponent = () => {
    return (
      <AboveTheFoldOnlyServerRender contextKey="aboveTheFoldOnlyServerRender.SomeComponent">
        <div>This will not be server side rendered based on the context.</div>
      </AboveTheFoldOnlyServerRender>
    );
};

class SomeApp extends React.Component {
  getChildContext() {
    return {
      aboveTheFoldOnlyServerRender: {
        SomeComponent: true
      }
    };
  }

  render() {
    return (
      <SomeComponent />
    );
  }
}

SomeApp.childContextTypes = {
  aboveTheFoldOnlyServerRender: React.PropTypes.shape({
    AnotherComponent: React.PropTypes.bool
  })
};

Development Guide

We have an ever-green guide to our development practices with this archetype. Click here before starting development on a component library.

Scripts

To run the demo:

gulp demo

To view the demo, navigate to http://localhost:4000

To view the demo with hot reload enabled, navigate to http://localhost:4000/webpack-dev-server/

To run tests:

gulp test

To build /lib:

gulp build

npm link

When using npm link, you must delete react from zeus-components-layout/node_modules/. This is because npm link is just a symlink, not a proper npm install.

You must also run gulp build

Built with :heart: by Team Electrode @WalmartLabs.