> For the complete documentation index, see [llms.txt](https://int-art.gitbook.io/scripty.sol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://int-art.gitbook.io/scripty.sol/building-html/requesting-dynamic-html.md).

# Requesting Dynamic HTML

`ScriptyBuilder` supports injecting dynamically created scripts between statically stored scripts.

If the `scriptContent` field of requests is not empty, then `ScriptyBuilder` will use `scriptContent` instead of fetching the script from a contract.

### Inline Script Request

```solidity
InlineScriptRequest[] memory requests = new InlineScriptRequest[](2);
requests[0].name = "three.js";
requests[0].contractAddress = scriptyStorageContractAddress;

requests[1].scriptContent = 'console.log("hello world!")';
```

### Wrapped Script Request

```solidity
WrappedScriptRequest[] memory requests = new WrappedScriptRequest[](2);
requests[0].name = "three.js";
requests[0].contractAddress = scriptyStorageContractAddress;

requests[1].wrapType = 0;
requests[1].scriptContent = 'console.log("hello world!")';
```

You can set different wrapping options for dynamically created scripts. For more about wrapping options please check [here](/scripty.sol/building-html/requesting-html-with-wrapped-scripts.md).

### Example

Here we are requesting `three.js` and some generative art named `cubes` that depends on `three.js`. By itself, cubes script does nothing. A controller script is created with on-chain values and it initiates `cubes` script.

<pre class="language-solidity"><code class="lang-solidity">InlineScriptRequest[] memory requests = new InlineScriptRequest[](3);
requests[0].name = "three.js";
requests[1].name = "cubes";

// Calculate this off-chain:
uint256 bufferSizeForStoredScripts = 100000;

bytes  memory controllerScript = abi.encodePacked(
    'let cubes = new Cubes("',
    LibString.toString(block.timestamp),
    '");'
);

requests[2].scriptContent = controllerScript;

// New buffer size to cover dynamically 
// created script
<strong>uint256 bufferSize = bufferSizeForStoredScripts + controllerScript.length;
</strong>
bytes  memory htmlFile = IScriptyBuilder(
    scriptyBuilderAddress
).getHTMLInline(
    requests, 
    controllerScript, 
    bufferSize
);
</code></pre>

When it's `controllerScript` becomes something like this:

```javascript
let cubes = new Cubes("1671835245");
```

Final output looks like this:

```html
<html>
    <body style='margin:0;'>
        <script>
            [three.js]
            [cubes]
            let cubes = new Cubes("1671835245");
        </script>
    </body>
</html>
```

You can check this example([contract](https://github.com/intartnft/scripty.sol/blob/main/contracts/examples/randomShapes/RandomShapes.sol), [deployment script](https://github.com/intartnft/scripty.sol/tree/main/examples/randomShapes)) which uses dynamic script to generate HTML files.
