Resource

Monster.DOM. Resource

This class is the base class for all resources to be loaded.

You can call the method via the monster namespace new Monster.DOM.Resource().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
new Monster.DOM.Resource()
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {Resource} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/dom/resource.js';
new Resource()
</script>

Constructor

# new Resource(options)

A Resource class

Parameters:
Name Type Description
options Object | undefined
Since:
  • 1.25.0

Classes

Data

A Data Resource class

Link

A Resource class

Script

A Resource class

Stylesheet

A Resource class

Members

# defaults

Properties
Name Type Description
document Document

the document object into which the node is to be appended

src/href string

url to the corresponding resource

query string

defines the location where the resource is to be hooked into the dom.

id string

element attribute id

title string

element attribute title

class string

element attribute class

timeout int

timeout

Methods

# (static) getURLAttribute() → {string}

Returns:
Type
string

# available() → {Promise}

With available() you can check if a resource is available. This is the case when the tag is included and the resource is loaded.

Returns:
Type
Promise

# connect() → {Monster.DOM.Resource}

This method appends the HTMLElement to the specified document. If the element has not yet been created, create() is called implicitly.

throws {Error} target not found

Returns:
Type
Monster.DOM.Resource

# create() → {Monster.DOM.Resource}

This method is overridden by the special classes and creates the DOM object. This method is also called implicitly, if not yet done explicitly, by calling connect().

Throws:

this method must be implemented by derived classes

Type
Error
Returns:
Type
Monster.DOM.Resource

# isConnected() → {boolean}

Returns:
Type
boolean