@@ -5,6 +5,19 @@ Feel free to have a look around! (We've commented the code so you can see what
5
5
everything does.)
6
6
*/
7
7
8
+ /*
9
+ Lazy load JS script files.
10
+ */
11
+ function script ( url ) {
12
+ var s = document . createElement ( 'script' ) ;
13
+ s . type = 'text/javascript' ;
14
+ s . async = false ;
15
+ s . defer = true ;
16
+ s . src = url ;
17
+ var x = document . getElementsByTagName ( 'head' ) [ 0 ] ;
18
+ x . appendChild ( s ) ;
19
+ }
20
+
8
21
/*
9
22
Returns an object that defines the behaviour of the Python editor. The editor
10
23
is attached to the div with the referenced id.
@@ -203,6 +216,25 @@ function web_editor(config) {
203
216
function setupFeatureFlags ( ) {
204
217
if ( config . flags . blocks ) {
205
218
$ ( "#command-blockly" ) . removeClass ( 'hidden' ) ;
219
+ // Add includes
220
+ script ( 'blockly/blockly_compressed.js' ) ;
221
+ script ( 'blockly/blocks_compressed.js' ) ;
222
+ script ( 'blockly/python_compressed.js' ) ;
223
+ script ( 'microbit_blocks/blocks/microbit.js' ) ;
224
+ script ( 'microbit_blocks/generators/accelerometer.js' ) ;
225
+ script ( 'microbit_blocks/generators/buttons.js' ) ;
226
+ script ( 'microbit_blocks/generators/compass.js' ) ;
227
+ script ( 'microbit_blocks/generators/display.js' ) ;
228
+ script ( 'microbit_blocks/generators/image.js' ) ;
229
+ script ( 'microbit_blocks/generators/microbit.js' ) ;
230
+ script ( 'microbit_blocks/generators/music.js' ) ;
231
+ script ( 'microbit_blocks/generators/neopixel.js' ) ;
232
+ script ( 'microbit_blocks/generators/pins.js' ) ;
233
+ script ( 'microbit_blocks/generators/radio.js' ) ;
234
+ script ( 'microbit_blocks/generators/speech.js' ) ;
235
+ script ( 'microbit_blocks/generators/python.js' ) ;
236
+ script ( 'blockly/msg/js/en.js' ) ;
237
+ script ( 'microbit_blocks/messages/en/messages.js' ) ;
206
238
}
207
239
if ( config . flags . snippets ) {
208
240
$ ( "#command-snippet" ) . removeClass ( 'hidden' ) ;
0 commit comments