[][src]Struct moxie_dom::elements::scripting::ScriptBuilder

#[must_use = "needs to be built"]pub struct ScriptBuilder { /* fields omitted */ }

The HTML <script> element is used to embed or reference executable code; this is typically used to embed or refer to JavaScript code.

A type for initializing the element's attributes before calling build.

Implementations

impl ScriptBuilder[src]

pub fn build(self) -> Script[src]

Initialize the element with all of the attributes so far.

impl ScriptBuilder[src]

pub fn async_(self, to_set: bool) -> Self[src]

For classic scripts, if the async attribute is present, then the classic script will be fetched in parallel to parsing and evaluated as soon as it is available.

For module scripts, if the async attribute is present then the scripts and all their dependencies will be executed in the defer queue, therefore they will get fetched in parallel to parsing and evaluated as soon as they are available.

This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. defer has a similar effect in this case.

pub fn crossorigin(self, to_set: impl ToString) -> Self[src]

Normal script elements pass minimal information to the window.onerror for scripts which do not pass the standard CORS checks. To allow error logging for sites which use a separate domain for static media, use this attribute.

pub fn defer(self, to_set: bool) -> Self[src]

Indicates to a browser that the script is meant to be executed after the document has been parsed, but before firing DOMContentLoaded.

Scripts with the defer attribute will prevent the DOMContentLoaded event from firing until the script has loaded and finished evaluating.

This attribute must not be used if the src attribute is absent (i.e. for inline scripts), in this case it would have no effect.

The defer attribute has no effect on module scripts — they defer by default.

Scripts with the defer attribute will execute in the order in which they appear in the document.

This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. async has a similar effect in this case.

pub fn integrity(self, to_set: impl ToString) -> Self[src]

This attribute contains inline metadata that a user agent can use to verify that a fetched resource has been delivered free of unexpected manipulation.

pub fn nomodule(self, to_set: bool) -> Self[src]

Indicates that the script should not be executed in browsers that support ES2015 modules — in effect, this can be used to serve fallback scripts to older browsers that do not support modular JavaScript code.

pub fn nonce(self, to_set: impl ToString) -> Self[src]

A cryptographic nonce (number used once) to whitelist scripts in a script-src Content-Security-Policy. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial.

pub fn referrerpolicy(self, to_set: ReferrerPolicy) -> Self[src]

Indicates which referrer to send when fetching the script, or resources fetched by the script.

pub fn src(self, to_set: impl ToString) -> Self[src]

This attribute specifies the URI of an external script; this can be used as an alternative to embedding a script directly within a document.

pub fn type_(self, to_set: impl ToString) -> Self[src]

This attribute indicates the type of script represented. The value of this attribute will be in one of the following categories:

  • Omitted or a JavaScript MIME type: This indicates the script is JavaScript. The HTML5 specification urges authors to omit the attribute rather than provide a redundant MIME type.
  • module: Causes the code to be treated as a JavaScript module. The processing of the script contents is not affected by the charset and defer attributes. Unlike classic scripts, module scripts require the use of the CORS protocol for cross-origin fetching.
  • Any other value: The embedded content is treated as a data block which won't be processed by the browser. Developers must use a valid MIME type that is not a JavaScript MIME type to denote data blocks. The src attribute will be ignored.

Trait Implementations

impl Element for ScriptBuilder[src]

impl<E> EventTarget<E> for ScriptBuilder where
    E: GlobalEvent
[src]

impl GlobalEventHandler for ScriptBuilder[src]

impl HtmlElement for ScriptBuilder[src]

impl Node for ScriptBuilder[src]

impl Parent<Text> for ScriptBuilder[src]

Auto Trait Implementations

impl !RefUnwindSafe for ScriptBuilder

impl !Send for ScriptBuilder

impl !Sync for ScriptBuilder

impl Unpin for ScriptBuilder

impl !UnwindSafe for ScriptBuilder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<N> Child for N where
    N: Node
[src]

impl<T> Downcast for T where
    T: Any

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.