diff --git a/Makefile b/Makefile
index f56d48150c..bcccf0b198 100644
--- a/Makefile
+++ b/Makefile
@@ -109,6 +109,14 @@ build/jsdoc-$(BRANCH)-timestamp: $(SRC) $(shell find doc/template -type f)
$(JSDOC) -t doc/template -r src -d build/gh-pages/$(BRANCH)/apidoc
touch $@
+.PHONY: hostexamples
+hostexamples: build examples
+ mkdir -p build/gh-pages/$(BRANCH)/examples
+ mkdir -p build/gh-pages/$(BRANCH)/build
+ cp $(EXAMPLES) $(subst .html,.js,$(EXAMPLES)) examples/style.css build/gh-pages/$(BRANCH)/examples/
+ cp build/loader_hosted_examples.js build/gh-pages/$(BRANCH)/examples/loader.js
+ cp build/ol.js build/ol.css build/gh-pages/$(BRANCH)/build/
+
.PHONY: test
test: $(INTERNAL_SRC)
$(PHANTOMJS) test/phantom-jasmine/run_jasmine_test.coffee test/ol.html
diff --git a/build/loader_hosted_examples.js b/build/loader_hosted_examples.js
new file mode 100644
index 0000000000..3ec22aa5e2
--- /dev/null
+++ b/build/loader_hosted_examples.js
@@ -0,0 +1,46 @@
+/**
+ *
+ * Loader to add ol.css, ol.js and the example-specific js file to the
+ * documents.
+ *
+ * This loader is used for the hosted examples. It is used in place of the
+ * development loader (examples/loader.js).
+ *
+ * ol.css and ol.js are built with Plovr/Closure, based build/ol.json.
+ * (`make build` should build them). They are located in the ../build/
+ * directory, relatively to this script.
+ *
+ * The script should be named loader.js. So it needs to be renamed to
+ * loader.js from loader_hosted_examples.js.
+ *
+ * Usage:
+ *
+ *
+ */
+
+(function() {
+ var scripts = document.getElementsByTagName('script');
+
+ var i, src, index, search, chunks, pair, params = {};
+ for (i = scripts.length - 1; i >= 0; --i) {
+ src = scripts[i].getAttribute('src');
+ if (~(index = src.indexOf('loader.js?'))) {
+ search = src.substr(index + 10);
+ chunks = search ? search.split('&') : [];
+ for (i = chunks.length - 1; i >= 0; --i) {
+ pair = chunks[i].split('=');
+ params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
+ }
+ break;
+ }
+ }
+
+ document.write('');
+ document.write('