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 d0a0bdc

Browse files
dynamic loading, lazy loading, preloading
1 parent 323fd09 commit d0a0bdc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,3 +1074,26 @@ xhr.send();
10741074
* sending HTTP response in chunks, browser can deal with this
10751075
* possible to send page header first, then page content, the script tags at the bottom
10761076
* these can be sent in different chunks, browser will progressively render
1077+
1078+
### dynamic script tag example
1079+
1080+
```js
1081+
//create script tag
1082+
var script = document.createElement('script');
1083+
script.src = 'my_script.js';
1084+
//append to head
1085+
document.documentElement.firstChild.appendChild(script);
1086+
```
1087+
1088+
* careful with multiple files (if they depend on each other)
1089+
* careful with what you append to (make sure it exists or use the script tag running the append)
1090+
1091+
### lazy loading
1092+
1093+
* dynamically loading (page-enhancing) JS on page onload
1094+
1095+
### preloading
1096+
1097+
* dinamically create object tag (to prevent execution)
1098+
* set src to js file, and width, height to 0
1099+
* next page will get that JS file from cache

0 commit comments

Comments
(0)

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