diff --git a/source/Html.mint b/source/Html.mint
index f5d5c86..6c89ce1 100644
--- a/source/Html.mint
+++ b/source/Html.mint
@@ -1,6 +1,6 @@
module Html {
/*
- Returns an empty Html node. It is useful for example if you dont to
+ Returns an empty Html node. It is useful for example if you dont want to
render something conditionally.
if (Array.isEmpty(items)) {
diff --git a/source/Http.mint b/source/Http.mint
index d1941f5..8458207 100644
--- a/source/Http.mint
+++ b/source/Http.mint
@@ -22,7 +22,7 @@ record Http.ErrorResponse {
/* Represents the possible failures of an HTTP request. */
enum Http.Error {
- /* The request cannot be loaded because of a network faliure */
+ /* The request cannot be loaded because of a network failure */
NetworkError
/* The client (browser) aborted the request */
@@ -89,7 +89,7 @@ module Http {
}
/*
- Creates a request record where the method is DELETE
+ Creates a request record where the method is GET
request =
Http.get("https://httpbin.org/get")
@@ -103,7 +103,7 @@ module Http {
}
/*
- Creates a request record where the method is DELETE
+ Creates a request record where the method is PUT
request =
Http.put("https://httpbin.org/put")
@@ -117,7 +117,7 @@ module Http {
}
/*
- Creates a request record where the method is DELETE
+ Creates a request record where the method is POST
request =
Http.post("https://httpbin.org/post")
diff --git a/source/Map.mint b/source/Map.mint
index 9b6dff5..b878168 100644
--- a/source/Map.mint
+++ b/source/Map.mint
@@ -6,7 +6,7 @@ module Map {
}
/*
- Sets the given value to the kiven key in the map.
+ Sets the given value to the given key in the map.
Map.empty()
|> Map.set("key", "value")
@@ -47,7 +47,7 @@ module Map {
}
/*
- Merges two maps together where the second has the precendence.
+ Merges two maps together where the second has the precedence.
a =
Map.empty()
diff --git a/source/Resource.mint b/source/Resource.mint
new file mode 100644
index 0000000..0be0970
--- /dev/null
+++ b/source/Resource.mint
@@ -0,0 +1,86 @@
+/* Functions for prebrowsing and resource hints. */
+module Resource {
+ /*
+ Pre-loads a given URL with a type of resource as soon as possible.
+
+ Resource.preLoad("https://example.com/fonts/font.woff", "font")
+
+ Resource Types: https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content#What_types_of_content_can_be_preloaded
+ */
+ fun preLoad (url : String, type : String) : Promise(Never, Void) {
+ `
+ (() => {
+ var preLoadLink = document.createElement("link");
+ preLoadLink.href = url;
+ preLoadLink.rel = "preload";
+ preLoadLink.as = type;
+ document.head.appendChild(preLoadLink);
+ })()
+ `
+ }
+
+ /*
+ Pre-fetches a given URL with a low priority.
+
+ Resource.preFetch("page-2.html")
+ */
+ fun preFetch (url : String) : Promise(Never, Void) {
+ `
+ (() => {
+ var preFetchLink = document.createElement("link");
+ preFetchLink.href = url;
+ preFetchLink.rel = "prefetch";
+ document.head.appendChild(preFetchLink);
+ })()
+ `
+ }
+
+ /*
+ Pre-fetches DNS of a given URL in the background.
+
+ Resource.preFetchDns("page-2.html")
+ */
+ fun preFetchDns (url : String) : Promise(Never, Void) {
+ `
+ (() => {
+ var preFetchDnsLink = document.createElement("link");
+ preFetchDnsLink.href = url;
+ preFetchDnsLink.rel = "dns-prefetch";
+ document.head.appendChild(preFetchDnsLink);
+ })()
+ `
+ }
+
+ /*
+ preRender tells the browser to download the entire page in the background.
+
+ Resource.preRender("http://example.com/services.html")
+ */
+ fun preRender (url : String) : Promise(Never, Void) {
+ `
+ (() => {
+ var preRenderLink = document.createElement("link");
+ preRenderLink.href = url;
+ preRenderLink.rel = "prerender";
+ document.head.appendChild(preRenderLink);
+ })()
+ `
+ }
+
+ /*
+ Establish a connection with given URL removing DNS lookup,
+ TCP handshake, and TLS negotiation round-trip for HTTPS.
+
+ Resource.preConnect("https://cdn.domain.com")
+ */
+ fun preConnect (url : String) : Promise(Never, Void) {
+ `
+ (() => {
+ var preConnectLink = document.createElement("link");
+ preConnectLink.href = url;
+ preConnectLink.rel = "preconnect";
+ document.head.appendChild(preConnectLink);
+ })()
+ `
+ }
+}