diff --git a/demo/requirejs.html b/demo/requirejs.html
index f99b77945a9db6c113def8ce4e590d270e077c69..438ef9fbf682e020869fa3fdec84485529815e54 100644
--- a/demo/requirejs.html
+++ b/demo/requirejs.html
@@ -38,14 +38,32 @@
 
     <div id="code"></div>
 
+    <button id="markdown">Dynamically load Markdown mode</button>
+
     <script type="text/javascript">
-      require(["../lib/codemirror", "../mode/htmlmixed/htmlmixed",
-               "../addon/hint/show-hint", "../addon/hint/html-hint"], function(CodeMirror) {
+      require.config({
+        packages: [{
+          name: "codemirror",
+          location: "../",
+          main: "lib/codemirror"
+        }]
+      });
+      require(["codemirror", "codemirror/mode/htmlmixed/htmlmixed",
+               "codemirror/addon/hint/show-hint", "codemirror/addon/hint/html-hint",
+               "codemirror/addon/mode/loadmode"], function(CodeMirror) {
         editor = CodeMirror(document.getElementById("code"), {
           mode: "text/html",
           extraKeys: {"Ctrl-Space": "autocomplete"},
           value: document.documentElement.innerHTML
         });
+
+        CodeMirror.modeURL = "codemirror/mode/%N/%N";
+        document.getElementById("markdown").addEventListener("click", function() {
+          CodeMirror.requireMode("markdown", function() {
+            editor.replaceRange("This is **Markdown**.\n\n", {line: 0, ch: 0});
+            editor.setOption("mode", "markdown");
+          });
+        });
       });
     </script>
   </article>