# script-ready **Repository Path**: mirrors_kaelzhang/script-ready ## Basic Information - **Project Name**: script-ready - **Description**: Detect if a DOMElement node is ready - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-07 - **Last Updated**: 2026-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![Build Status](https://travis-ci.org/kaelzhang/script-ready.svg?branch=master)](https://travis-ci.org/kaelzhang/script-ready) # script-ready Detect or wait until if a script node is ready ## Install ```sh $ npm i script-ready ``` ## Usage ```js import { // Check if the given script is exists in the dom exists, // Wait until the script is ready loaded } from 'script-ready' exists('a.js') // true loaded('b.js').then(node => { // The `HTMLScriptElement` node of the script console.log(node) }) ``` ## exists(tester, {parent}) -> boolean Returns `true` if the script node already exists - **tester** - `string`: sub string of the `node.src` - `RegExp`: regular expression to test the `node.src` - `Function(node: HTMLScriptElement) -> boolean` tester function to test the [`HTMLScriptElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement) - **parent** `document | 'head' | 'body'` the parent element to test the script node from ## async loaded(tester, {parent}) -> node Wait until the script node is loaded ## License [MIT](LICENSE)