@@ -1010,7 +1010,7 @@ oldnode.parentNode.replaceChild(clone, oldNode);
1010
1010
1011
1011
* javascript runs on a single thread in the browser
1012
1012
* web workers: background thread support by the browser
1013
- * only in modern browsers
1013
+ * only in modern browsers (from IE 10)
1014
1014
* you put worker code in a separate file
1015
1015
* worker can use ```postMessage``` to send messages to the caller
1016
1016
* caller can subscribe to messages using ```Worker.onMessage```
@@ -1038,3 +1038,32 @@ xhr.onreadystatechange = function handleResponse() {
1038
1038
xhr.open('GET', 'page.html', true);
1039
1039
xhr.send();
1040
1040
```
1041
+
1042
+ ### JSONP
1043
+
1044
+ * JSON with padding
1045
+ * not restricted by same origin policy (but really you should just setup CORS properly)
1046
+ * callback parameter in URL specifies the JS function handling the response
1047
+ * server should return data passed into the callback function as parameter
1048
+
1049
+ ### Image beacons
1050
+
1051
+ * even without javascript, data can be sent to the server
1052
+ * include an img tag (typically 1x1 transpatrent PNG)
1053
+ * actually better to respond with 204 No Content (old IE version might not like this)
1054
+ * browser makes a request when the page is being loaded
1055
+
1056
+ ### combining scripts, minification, caching
1057
+
1058
+ * concatenate scripts to reduce number of HTTP requests
1059
+ * loosing some of the granular caching benefits
1060
+ * have to come up with versioning scheme
1061
+ * minify to reduce script size
1062
+ * use source maps to still allow easy debugging
1063
+ * use cache headers properly (browsers don't cache for too long by default)
1064
+
1065
+ ### script tag location and attributes
1066
+
1067
+ * don't use language or type attribute as browsers assume JS anyways
1068
+ * script tags (by default) block page loading until they're downloaded, parsed and run
1069
+ * put your script tags at the bottom of the page or use HTML5 async script (since IE10)
0 commit comments