Link
A link resource for attaching external link-based assets such as stylesheets or preloads.
import { Link } from "@schukai/monster/source/dom/resource/link.mjs";Link represents a DOM link resource such as a stylesheet, preload or related external asset. It wraps the browser's <link> element in the shared Monster resource lifecycle.
Use it when loading behavior needs to be explicit and configurable instead of being scattered through ad-hoc DOM mutations.
Create And Connect A Link Resource
import { Link } from "@schukai/monster/source/dom/resource/link.mjs";
const output = document.getElementById("link-output");
document.getElementById("link-run").addEventListener("click", () => {
const link = new Link({
href: "/assets/demo.css",
rel: "stylesheet",
document,
query: "head",
});
output.textContent = JSON.stringify(
{
href: link.getOption("href"),
rel: link.getOption("rel"),
query: link.getOption("query"),
},
null,
2,
);
});Exported
LinkDerived from
ResourceOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the Resource.
Properties
The Properties listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits Properties from these parent classes. If you cannot find a specific Properties in this list, we recommend consulting the documentation of the Resource.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the Resource.
Behavioral methods
create()- {Monster.DOM.Resource.Link}
Static methods
[instanceSymbol]()2.1.0- {symbol}
instanceof operator.getURLAttribute()- {string}
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.