Skip to content

Commit a86f0f4

Browse files
committed
updated extensions.md
1 parent b2fb4c6 commit a86f0f4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

DEVLOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
* **Translation Updates:**
101101
* German
102102

103+
### 2024-06-10
104+
* updated extensions.md with autoloading mechanism
105+
103106
### 2024-06-07
104107
* blocks: correctly record block snaps in "when () is edited" data, thanks, @dardoro, for the bug report!
105108
* objects: include customized primitives when enumerating primitive instances

docs/Extensions.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Snap! Extensions
22

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

124+
#### autoloading JavaScript files
125+
126+
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.
127+
124128
### 5. Miscellaneous
125129

126130
#### calling extension primitives in other JavaScript functions

0 commit comments

Comments
 (0)