Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4132e4a

Browse files
loading javascript
1 parent 7fccd1c commit 4132e4a

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

‎readme.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ oldnode.parentNode.replaceChild(clone, oldNode);
10101010
10111011
* javascript runs on a single thread in the browser
10121012
* web workers: background thread support by the browser
1013-
* only in modern browsers
1013+
* only in modern browsers (from IE 10)
10141014
* you put worker code in a separate file
10151015
* worker can use ```postMessage``` to send messages to the caller
10161016
* caller can subscribe to messages using ```Worker.onMessage```
@@ -1038,3 +1038,32 @@ xhr.onreadystatechange = function handleResponse() {
10381038
xhr.open('GET', 'page.html', true);
10391039
xhr.send();
10401040
```
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /