NAME
HTML::Object::DOM::Element::Script - HTML Object DOM Script Class
SYNOPSIS
use HTML::Object::DOM::Element::Script;
my $script = HTML::Object::DOM::Element::Script->new ||
die( HTML::Object::DOM::Element::Script->error, "\n" );
VERSION
v0.2.0
DESCRIPTION
This implements the interface for <script
> elements, which provides special properties and methods for manipulating the behavior and execution of <script
> elements (beyond the inherited HTML::Object::Element interface).
INHERITANCE
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Script |
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
PROPERTIES
Inherits properties from its parent HTML::Object::DOM::Element
async
The async and defer attributes are boolean attributes that control how the script should be executed. The defer
and async
attributes must not be specified if the src attribute is absent.
There are three possible execution modes:
- 1. If the async attribute is present, then the script will be executed asynchronously as soon as it downloads.
- 2. If the async attribute is absent but the defer attribute is present, then the script is executed when the page has finished parsing.
- 3. If neither attribute is present, then the script is fetched and executed immediately, blocking further parsing of the page.
The defer
attribute may be specified with the async
attribute, so legacy browsers that only support defer (and not async) fall back to the defer behavior instead of the default blocking behavior.
Note: The exact processing details for these attributes are complex, involving many different aspects of HTML, and therefore are scattered throughout the specification. These algorithms describe the core ideas, but they rely on the parsing rules for <script
> start and end tags in HTML, in foreign content, and in XML; the rules for the document.write()
method; the handling of scripting; and so on.
See also Mozilla documentation
charset
Is a string representing the character encoding of an external script. It reflects the charset attribute.
See also Mozilla documentation
crossOrigin
Is a string reflecting the CORS setting for the script element. For scripts from other origins, this controls if error information will be exposed.
See also Mozilla documentation
defer
The defer
attribute may be specified even if the async
attribute is specified, to cause legacy web browsers that only support defer (and not async) to fall back to the defer behavior instead of the blocking behavior that is the default.
event
Is a string; an obsolete way of registering event handlers on elements in an HTML document.
See also Mozilla documentation
noModule
Is a boolean value that if true, stops the script's execution in browsers that support ES2015 modules — used to run fallback scripts in older browsers that do not support JavaScript
modules.
See also Mozilla documentation
referrerPolicy
Is a string that reflects the referrerpolicy HTML attribute indicating which referrer to use when fetching the script, and fetches done by that script.
Example:
my $scriptElem = $doc->createElement( 'script' );
$scriptElem->src = '/';
$scriptElem->referrerPolicy = 'unsafe-url';
$doc->body->appendChild( $scriptElem );
See also Mozilla documentation
src
Is a string representing the URL of an external script. It reflects the src HTML attribute. You can get and set an URI object.
See also Mozilla documentation
text
Is a string that joins and returns the contents of all Text nodes inside the <script
> element (ignoring other nodes like comments) in tree order. On setting, it acts the same way as the textContent IDL attribute.
Note: When inserted using the document.write() method, <script> elements execute (typically synchronously), but when inserted using innerHTML or outerHTML, they do not execute at all.
See also Mozilla documentation
type
Is a string representing the MIME type of the script. It reflects the type HTML attribute.
See also Mozilla documentation
METHODS
Inherits methods from its parent HTML::Object::DOM::Element
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
Mozilla documentation, Mozilla documentation on script element, W3C specifications
COPYRIGHT & LICENSE
Copyright(c) 2021 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.