Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/deps/usehooks-ts.ts>useScript

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function useScript
import { useScript } from "https://deno.land/x/netzo@0.4.72/deps/usehooks-ts.ts";

Custom hook for dynamically loading scripts and tracking their loading status.

Examples

const scriptStatus = useScript('https://example.com/script.js', { removeOnUnmount: true }); // Access the status of the script loading (e.g., 'loading', 'ready', 'error').

Parameters

src: string | null
  • The source URL of the script to load. Set to null or omit to prevent loading (optional).
optional
options: UseScriptOptions
  • Additional options for controlling script loading (optional).

Returns

UseScriptStatus

The status of the script loading, which can be one of 'idle', 'loading', 'ready', or 'error'.