Skip to content

Commit

Permalink
updated extensions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoenig committed Jun 10, 2024
1 parent b2fb4c6 commit a86f0f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions DEVLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
* **Translation Updates:**
* German

### 2024-06-10
* updated extensions.md with autoloading mechanism

### 2024-06-07
* blocks: correctly record block snaps in "when () is edited" data, thanks, @dardoro, for the bug report!
* objects: include customized primitives when enumerating primitive instances
Expand Down
6 changes: 5 additions & 1 deletion docs/Extensions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Snap! Extensions

> Last updated May 23, 2024
> Last updated June 10, 2024
Snap! Extensions take the idea of a library, and expand it by allowing you to add your own JavaScript code.
Much of the work happens through two (hidden) primitive blocks.
Expand Down Expand Up @@ -121,6 +121,10 @@ This lets you lazily initialize your extension by simply adding a
"src_load(url)" command for your external JS file before calling any of its
added functions.

#### autoloading JavaScript files

If you want a library of custom blocks to automatically also load an external JavaScript file - and possibly also perform an initialization - you can include a global variable in the blocks library whose name has to begin with the word "module" enclosed in double-underscores (``__module__``), and whose value can be the url of a JavaScript file to be loaded. Notice that you can hide such a variable in the palette so the user will not be confused by its presence.

### 5. Miscellaneous

#### calling extension primitives in other JavaScript functions
Expand Down

0 comments on commit a86f0f4

Please sign in to comment.