
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
gatsby-plugin-js-fallback
Advanced tools
Gatsby plugin to fallback gracefully when JS is disabled on client side
Gatsby plugin to fallback gracefully when JS is disabled on client side.
// In your gatsby-config.js
module.exports = {
plugins: [
`gatsby-plugin-js-fallback`
// ... other plugins
]
};
Then in the React components/page that you would like to provide a fallback when JavaScript is disabled on client side:
import React from 'react';
import { useIsJsEnabled } from 'gatsby-plugin-js-fallback';
const GracefulPage = () => {
const isJsEnabled = useIsJsEnabled();
return isJsEnabled ? <MyFancyComponentThatNeedJs /> : <SimpleComponent />;
};
useIsJsEnabled
would returns false
, thus the pre-rendered HTML will contain the fallback UI that does not rely on JavaScript.useIsJsEnabled
would returns true
, then the UI that relies on JavaScript will be displayed.useIsJsEnabled
A custom hooks that only returns true
when your Gatsby site hydrate successfully on client side.
Sometimes, you want to introduce some components in your Gatsby site that rely heavily on JavaScript. However, this would cause your site non-usable when JavaScript is disabled on client side.
There are two approaches to deal with this:
This plugin allows you to implement second approach.
There may be content flash from the fallback UI to the enhanced UI at initial page/page refresh. This is because the pre-rendered HTML (that contains the fallback UI) will be displayed while the page is downloading all the js files and then detect if JS is enabled.
There is no solution to avoid this content flash at the moment. If you have any suggestion, raise an issue at let me know!
FAQs
Gatsby plugin to fallback gracefully when JS is disabled on client side
The npm package gatsby-plugin-js-fallback receives a total of 25 weekly downloads. As such, gatsby-plugin-js-fallback popularity was classified as not popular.
We found that gatsby-plugin-js-fallback demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.