Class Script


@Bean(typeName="script") public class Script extends HtmlElementRawText
DTO for an HTML <script> element.

The script element is used to embed or reference executable code, typically JavaScript. It can contain inline script code or reference external script files. The script element is commonly used to add interactivity and dynamic behavior to web pages.

Examples:

import static org.apache.juneau.bean.html5.HtmlBuilder.*; // Inline JavaScript Script script1 = script() .text("console.log('Hello, World!');"); // External JavaScript file Script script2 = script() .src("https://example.com/script.js") .type("text/javascript"); // Async script loading Script script3 = script() .src("https://example.com/analytics.js") .async(true) .defer(true); // Script with integrity check Script script4 = script() .src("https://example.com/library.js") .integrity("sha384-...") .crossorigin("anonymous"); // Module script Script script5 = script() .src("https://example.com/module.js") .type("module");

The following convenience methods are provided for constructing instances of this bean:

See Also: