---
title: "tinymce.dom.ScriptLoader"
description: "This class handles asynchronous/synchronous loading of JavaScript files it will execute callbacks when various items gets loaded. This class is useful to load external JavaScript files."
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.dom.scriptloader/"
md_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.dom.scriptloader/index.md"
version: "latest"
last_updated: "2025-10-23T01:37:47Z"
tokens: 922
---
# tinymce.dom.ScriptLoader

This class handles asynchronous/synchronous loading of JavaScript files it will execute callbacks when various items gets loaded. This class is useful to load external JavaScript files.

## Examples

```javascript
// Load a script from a specific URL using the global script loader
tinymce.ScriptLoader.load('somescript.js');

// Load a script using a unique instance of the script loader
const scriptLoader = new tinymce.dom.ScriptLoader();

scriptLoader.load('somescript.js');

// Load multiple scripts
scriptLoader.add('somescript1.js');
scriptLoader.add('somescript2.js');
scriptLoader.add('somescript3.js');

scriptLoader.loadQueue().then(() => {
  alert('All scripts are now loaded.');
});
```

## Summary

### Methods

| Name | Summary | Defined by |
| --- | --- | --- |
| [add()](#add) | Adds a specific script to the load queue of the script loader. | `ScriptLoader` |
| [getScriptAttributes()](#getScriptAttributes) | Returns the attributes that should be added to a script tag when loading the specified URL. | `ScriptLoader` |
| [isDone()](#isDone) | Returns true/false if a script has been loaded or not. | `ScriptLoader` |
| [loadQueue()](#loadQueue) | Starts the loading of the queue. | `ScriptLoader` |
| [loadScript()](#loadScript) | Loads a specific script directly without adding it to the load queue. | `ScriptLoader` |
| [loadScripts()](#loadScripts) | Loads the specified queue of files and executes the callback ones they are loaded. This method is generally not used outside this class but it might be useful in some scenarios. | `ScriptLoader` |
| [markDone()](#markDone) | Marks a specific script to be loaded. This can be useful if a script got loaded outside the script loader or to skip it from loading some script. | `ScriptLoader` |

## Methods

### add()

```javascript
add(url: String): Promise
```
Adds a specific script to the load queue of the script loader.

#### Parameters

- `url (String)` - Absolute URL to script to add.

#### Return value

- `Promise` - A promise that will resolve when the script loaded successfully or reject if it failed to load.

### getScriptAttributes()

```javascript
getScriptAttributes(url: String): Object
```
Returns the attributes that should be added to a script tag when loading the specified URL.

#### Parameters

- `url (String)` - Url to get attributes for.

#### Return value

- `Object` - Object with attributes to add to the script tag.

### isDone()

```javascript
isDone(url: String): Boolean
```
Returns true/false if a script has been loaded or not.

#### Parameters

- `url (String)` - URL to check for.

#### Return value

- `Boolean` - true/false if the URL is loaded.

### loadQueue()

```javascript
loadQueue(): Promise
```
Starts the loading of the queue.

#### Return value

- `Promise` - A promise that is resolved when all queued items are loaded or rejected with the script urls that failed to load.

### loadScript()

```javascript
loadScript(url: String): Promise
```
Loads a specific script directly without adding it to the load queue.

#### Parameters

- `url (String)` - Absolute URL to script to add.

#### Return value

- `Promise` - A promise that will resolve when the script loaded successfully or reject if it failed to load.

### loadScripts()

```javascript
loadScripts(scripts: Array): Promise
```
Loads the specified queue of files and executes the callback ones they are loaded.
This method is generally not used outside this class but it might be useful in some scenarios.

#### Parameters

- `scripts (Array)` - Array of queue items to load.

#### Return value

- `Promise` - A promise that is resolved when all scripts are loaded or rejected with the script urls that failed to load.

### markDone()

```javascript
markDone(url: String)
```
Marks a specific script to be loaded. This can be useful if a script got loaded outside
the script loader or to skip it from loading some script.

#### Parameters

- `url (String)` - Absolute URL to the script to mark as loaded.
