From: Hakim El Hattab Date: Sun, 12 Aug 2012 00:52:56 +0000 (-0300) Subject: document dependency loading X-Git-Tag: 2.0.0~31 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=95898dc9e37046d9cd484159ed2700e89aa3abae;p=reveal.js.git document dependency loading --- diff --git a/README.md b/README.md index 3266848..12b931f 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,26 @@ Reveal.initialize({ }); ``` +### Dependencies + +Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example: + +```javascript +Reveal.initialize({ + dependencies: [ + { src: 'lib/js/highlight.js', async: true, callback: function() { window.hljs.initHighlightingOnLoad(); } }, + { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } } + ] +}); +``` + +You can add your own extensions using the same syntax. The following properties are available for each dependency object: +- **src**: Path to the script to load +- **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false +- **callback**: [optional] Function to execute when the script has loaded +- **condition**: [optional] Function which must return true for the script to be loaded + + ### API The Reveal class provides a minimal JavaScript API for controlling navigation and reading state: