posthtml-noscript
posthtml-noscript
is a PostHTML plugin to insert noscript content.
Use Cases:
- Display a "Enable JavaScript" message in a Single Page Application (SPA)
- Specify resource link elements (e.g. stylesheets) to load if JavaScript is disabled
Before:
After:
You need to enable JavaScript to run this app.
Install
yarn add -D posthtml-noscript# OR npm i posthtml-noscript
Usage
const fs = ;const posthtml = ;const noscript = ; const html = fs; ;
Options
By default, the plugin prepends noscript markup inside the body tag.
Optionally, specify "head" as the parent tag to insert noscript content inside the head tag.
Before:
In this example, custom fonts are loaded via Adobe Typekit using JavaScript. Without a resource link fallback, custom fonts can't be loaded.
Config:
const fs = ;const posthtml = ;const noscript = ; const html = fs; ;
After:
If JavaScript is disabled, custom fonts can still be loaded.
Contributing
See the PostHTML Guidelines.