32.0.0 • Published 1 year ago

tachyon-polyfill v32.0.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
1 year ago

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 });
32.0.0

1 year ago