@@ -242,58 +242,67 @@ var Reveal = (function(){
242242
243243 }
244244
245- /**
246- * Loads the dependencies of reveal.js. Dependencies are
247- * defined via the configuration option 'dependencies'
248- * and will be loaded prior to starting/binding reveal.js.
249- * Some dependencies may have an 'async' flag, if so they
250- * will load after reveal.js has been started up.
251- */
252- function load ( ) {
253-
254- var scripts = [ ] ,
255- scriptsAsync = [ ] ;
256-
257- for ( var i = 0 , len = config . dependencies . length ; i < len ; i ++ ) {
258- var s = config . dependencies [ i ] ;
259-
260- // Load if there's no condition or the condition is truthy
261- if ( ! s . condition || s . condition ( ) ) {
262- if ( s . async ) {
263- scriptsAsync . push ( s . src ) ;
264- }
265- else {
266- scripts . push ( s . src ) ;
267- }
268-
269- // Extension may contain callback functions
270- if ( typeof s . callback === 'function' ) {
271- head . ready ( s . src . match ( / ( [ \w \d _ \- ] * ) \. ? j s $ | [ ^ \\ \/ ] * $ / i ) [ 0 ] , s . callback ) ;
272- }
273- }
274- }
275-
276- // Called once synchronous scripts finish loading
277- function proceed ( ) {
278- if ( scriptsAsync . length ) {
279- // Load asynchronous scripts
280- head . js . apply ( null , scriptsAsync ) ;
281- }
282-
283- start ( ) ;
284- }
285-
286- if ( scripts . length ) {
287- scripts . push ( proceed ) ;
288-
289- // Load synchronous scripts
290- head . js . apply ( null , scripts ) ;
291- }
292- else {
293- proceed ( ) ;
294- }
295-
296- }
245+ /**
246+ * Loads the dependencies of reveal.js. Dependencies are
247+ * defined via the configuration option 'dependencies'
248+ * and will be loaded prior to starting/binding reveal.js.
249+ * Some dependencies may have an 'async' flag, if so they
250+ * will load after reveal.js has been started up.
251+ */
252+ function load ( ) {
253+ var scripts = [ ] ,
254+ scriptsAsync = [ ] ,
255+ scriptsToApply = 0 ;
256+
257+ // Called once synchronous scripts finish loading
258+ function proceed ( ) {
259+ if ( scriptsAsync . length ) {
260+ // Load asynchronous scripts
261+ head . js . apply ( null , scriptsAsync ) ;
262+ }
263+
264+ start ( ) ;
265+ }
266+
267+ for ( var i = 0 , len = config . dependencies . length ; i < len ; i ++ ) {
268+ var s = config . dependencies [ i ] ;
269+
270+ // Load if there's no condition or the condition is truthy
271+ if ( ! s . condition || s . condition ( ) ) {
272+ if ( s . async ) {
273+ scriptsAsync . push ( s . src ) ;
274+ }
275+ else {
276+ scripts . push ( s . src ) ;
277+ }
278+
279+ // Extension may contain callback functions
280+ ( function ( s ) {
281+ head . ready ( s . src . match ( / ( [ \w \d _ \- ] * ) \. ? j s $ | [ ^ \\ \/ ] * $ / i ) [ 0 ] , function ( ) {
282+ if ( typeof s . callback === 'function' ) {
283+ s . callback . apply ( this ) ;
284+ }
285+
286+ scriptsToApply -- ;
287+ if ( scriptsToApply === 0 ) {
288+ proceed ( ) ;
289+ }
290+ } ) ;
291+ } ) ( s ) ;
292+ }
293+ }
294+
295+ if ( scripts . length ) {
296+ scriptsToApply = scripts . length ;
297+
298+ // Load synchronous scripts
299+ head . js . apply ( null , scripts ) ;
300+ }
301+ else {
302+ proceed ( ) ;
303+ }
304+
305+ }
297306
298307 /**
299308 * Starts up reveal.js by binding input events and navigating
0 commit comments