@get-catch/catchjs
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Catch.js ES Module

This package provides an ES module for loading Catch.js asynchronously, as an alternative to the basic method of including a script tag directly in your HTML (which blocks page rendering).

Installation

Install the package using npm (or yarn, or similar):

npm install @get-catch/catchjs

Usage

Use the loadCatchjs(options) function to load Catch.js asynchronously:

import { loadCatchjs } from "@get-catch/catchjs";

const catchjs = await loadCatchjs();

Catch.js may be loaded in either "sandbox" mode (intended for dev/test environments) or "live" mode (for production). By default, loadCatchjs() will load the sandbox mode. For live mode, pass an options argument to loadCatchjs() with the entry live: true:

const catchjs = await loadCatchjs({
  live: true, // true for "live" mode, false for "sandbox" mode
});

loadCatchjs() returns a Promise that resolves with the catchjs namespace object once Catch.js has loaded, and rejects if Catch.js fails to load. This function should only be invoked in a browser or browser-like environment (i.e. when window is defined), and will reject if invoked in a server environment.

Once loaded, Catch.js must still be initialized by calling catchjs.init() (please refer to the initialization docs).

TypeScript Support

This package ships with TypeScript declarations for the loading utility, as well as the Catch.js SDK itself.

Package Sidebar

Install

npm i @get-catch/catchjs

Weekly Downloads

21

Version

1.1.0

License

MIT

Unpacked Size

18.4 kB

Total Files

10

Last publish

Collaborators

  • whitney-catch
  • levcatch
  • catch-sysadmin