Stay organized with collections
Save and categorize content based on your preferences.
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(hasCss: boolean, pathToMedia: string): void;
Parameters
Parameter |
Type |
Description |
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
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["The `Css.inject()` function dynamically adds Blockly's CSS to the webpage, enhancing performance by avoiding a separate HTTP request and redraw."],["This function accepts a boolean `hasCss` flag to control CSS injection and a `pathToMedia` string specifying the location of Blockly's media files."],["Using `Css.inject()` is generally preferred over a traditional CSS file for its synchronous loading, loading speed improvement, and dynamic CSS capability."]]],[]]