HTML::O...:Script(3)
πΈ NAME
HTML::Object::DOM::Element::Script β the HTML Object DOM Script Class, aka the little object that runs the show when your page says "hey, run this script" π
Oh and real quick, bestie β this whole thing lives in the User Contributed Perl Documentation section of the manual, and the page you're reading is literally titled HTML::O...:Script(3) (they truncated it, the disrespect π). But it's the Script element page. Periodt.
β¨ SYNOPSIS
Ok so the whole flex is like three lines:
use HTML::Object::DOM::Element::Script;
my $script = HTML::Object::DOM::Element::Script->new ||
die( HTML::Object::DOM::Element::Script->error, "\n" );
That's it. That's the vibe. Create it or die trying π«Ά
π VERSION
We're on v0.2.0 β small number, big energy π
π DESCRIPTION
So what this class actually does: it implements the interface for <script elements. Yep β those scripty little guys. It gives you the special properties and methods for messing with how a <script element behaves and executes β everything beyond what it already inherits from the HTML::Object::Element interface. Main character energy, honestly π
(And yes, the stray quote in <script is canon, it's in the original, ngl it's giving typo chic π)
π¦ INHERITANCE
Here's the whole family tree, bestie. It's a whole lineage:
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Script |
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+
Look at all those ancestors. Generational talent, fr fr β¨
π PROPERTIES
It inherits properties from its parent HTML::Object::DOM::Element β so everything there is yours too, plus this stuff:
π΄ async
So the async and defer attributes are boolean attributes, and they're the ones that control how the script gets executed. Lowkey important detail: the defer and async attributes must not be specified if the src attribute is absent. Not optional. Don't do it π«
There are three possible execution modes, and I need you to memorize these:
- If the
asyncattribute is present, then the script will be executed asynchronously as soon as it downloads. Immediate slay. - If the
asyncattribute is absent but thedeferattribute is present, then the script is executed when the page has finished parsing. Patient queen behavior. - If neither attribute is present, then the script is fetched and executed immediately, blocking further parsing of the page. Rude of it, honestly, but that's the default.
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. Backwards compatibility icon π«Ά
Note: the exact processing details for these attributes are complex β they involve many different aspects of HTML, so they're scattered all throughout the specification. These algorithms describe the core ideas, but they rely on the parsing rules for<scriptstart and end tags in HTML, in foreign content, and in XML; the rules for thedocument.write()method; the handling of scripting; and so on. So likeβ¦ it's complicated. Iykyk.
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/async
π€ charset
A string representing the character encoding of an external script. It reflects the charset attribute. Cute and simple π
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/charset
π crossOrigin
A string that reflects the CORS setting for the script element. For scripts coming from other origins, this controls whether error information will be exposed or not. Cross-origin drama, but make it configurable π¦
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/crossOrigin
β³ defer
The defer attribute may be specified even if the async attribute is specified β the whole point is 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. Give the old browsers a soft landing π
π event
It's a string β and it's an obsolete way of registering event handlers on elements in an HTML document. Deprecated, bestie. It's giving 2009. Don't build new stuff on it π
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/event
π« noModule
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. It's the "you probably weren't invited" flag π
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/noModule
π΅οΈ referrerPolicy
A string that reflects the referrerpolicy HTML attribute, indicating which referrer to use when fetching the script β and the fetches done by that script, too. It's a whole chain of trust situation.
Example time, look at this little cutie:
my $scriptElem = $doc->createElement( 'script' );
$scriptElem->src = '/';
$scriptElem->referrerPolicy = 'unsafe-url';
$doc->body->appendChild( $scriptElem );
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/referrerPolicy
π src
A string representing the URL of an external script. It reflects the src HTML attribute. And the fun part: you can get and set an URI object on it. Flexible king π
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/src
π text
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. So it's basically the content but only the text bits, okurrr π
Note: when inserted using thedocument.write()method,<script>elements execute (typically synchronously) β but when inserted usinginnerHTMLorouterHTML, they do not execute at all. That's the trap. Write it down. π¨
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/text
π·οΈ type
A string representing the MIME type of the script. It reflects the type HTML attribute. Classic. Iconic. Essential.
See also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/type
π₯ METHODS
It inherits methods from its parent HTML::Object::DOM::Element β nothing extra listed here, and honestly the inherited toolkit is already a whole mood π
π AUTHOR
Jacques Deguest <jack@deguest.jp> β the mastermind behind this whole thing. We stan π«Ά
π SEE ALSO
- Mozilla documentation
https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement - Mozilla documentation on script element
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script - W3C specifications
https://html.spec.whatwg.org/multipage/scripting.html#htmlscriptelement
Go read the specs bestie, they're long but they're worth it π
π 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. Open source baddie behavior, we love to see it π
Alright that's the whole page! π§ Quick sign-off with the boring-but-required bits: this was generated by perl v5.42.2 and dated 2026-02-15 β so if you're reading this way in the future, hi, love you, the facts still hold πΈπ
π¦ where this page comes from
- alpine 3.24: perl-html-object-doc 0.6.0-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms