Skip to main content

blockly > Css > inject

Css.inject() function

Inject the CSS into the DOM. This is preferable over using a regular CSS file since: a) It loads synchronously and doesn't force a redraw later. b) It speeds up loading by not blocking on a separate HTTP transfer. c) The CSS content may be made dynamic depending on init options.

Signature:

export declare function inject(container: HTMLElement, hasCss: boolean, pathToMedia: string): void;

Parameters

Parameter

Type

Description

container

HTMLElement

The div or other HTML element into which Blockly was injected.

hasCss

boolean

If false, don't inject CSS (providing CSS becomes the document's responsibility).

pathToMedia

string

Path from page to the Blockly media directory.

Returns:

void