tachyon-polyfill
v32.0.0
Published
Consume Twitch's Polyill Service
Downloads
2
Readme
Tachyon-Polyfill
A package to polyfill Browser features via Twitch's hosted version of Polyfill.io. Currently we only support v2 of Polyfill.io.
Installation
yarn add tachyon-polyfill
React Apps
import type { FC } from 'react';
import { PolyfillPreload, PolyfillScript } from 'tachyon-polyfill';
const App: FC = ({ userLocale }) => {
return (
<html>
<head>
{/* Optional: ensures this script download is priortized for perf reasons */}
<PolyfillPreload locale={userLocale} />
</head>
<body>
{/* Place above all app scripts to ensure availability of features */}
<PolyfillScript locale={userLocale} />
<script src="app.js" />
</body>
</html>
);
};
For Other Apps
For non-React applications we also expose the more primitive getPolyfillUrl
which will return you a string that can be templated into an HTML script
elements.
import { getPolyfillUrl } from 'tachyon-polyfill';
const polyfillUrl = getPolyfillUrl({ userLocale });