Code Splitting
@medikoo is already working on this.
Since Mar 9, 2012.
Assessment
This issue has not been assessed yet.
Description
GWT has a cool feature named Code Splitting which loads parts of the code on demand. This is also appliable for webmake.
Here my idea:
// a.js:
var b = require("b");
// ...
bindEventHandlerForSomeRarEvent(function() {
// the magic keyword "process.nextTick", which behaves normally in node.js
// but so some special thing in webmake
process.nextTick(function(err) {
// Some code loading err handler
// err is undefined in node.js
if(err) { /* ... */ }
var c = require("c"); // really big libary, which is only needed in this rar case
// ...
});
});
webmake core would provide the magic process.nextTick function to the compiled code.
process.nextTick do this in the compiled code:
- store the callback function
- adds a script tag to the document
- the script contains JSONP
- callback function (JSONP) adds some new modules to the context
- and calls the stored callback function.
- in case of an error (ex. timeout) the stored callback function is called with some kind of error parameter
Here is a quick hint on the compiled files:
// output.js
( /* core code */
({
"a": function(/* ... */, process) {
// a.js:
var b = require("b");
// ...
bindEventHandlerForSomeRarEvent(function() {
// the magic keyword, which behaves normally in node.js
// but so some special thing in webmake
process.nextTick(function(err) {
// Some code loading err handler
// err is undefined in node.js
if(err) { /* ... */ }
var c = require("c"); // really big libary,
// which is only needed in this rar case
// ...
});
});
},
"b": function /* content of b.js */
// here is no "c": !!
// which saves bandwidth
// may be named "a.output.js":
webmake_magic_jsonp_function( // the jsonp callback function
"a", // origin of code loading (used for identifing the stored function)
{
"c": function(/* ... */, process) {
// the content of the big libary
},
"d": function(/* ... */, process) {
// d.js is here a dependency of c.js (optional)
}
}
This feature may makes the compile process a big complexer.
It may be useful for:
- loading parts of your webapp when accessing them
- loading polyfills only when necessary
- decrease startup time
- Dominant language
- JavaScript
- Stars
- 412
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from medikoo/modules-webmake
-
How to use the fs node module with this?May be free again @Kali95739 claimed this 1502 days ago, and no pull request is open. Openquestion
medikoo/modules-webmake#59 · 3 comments · 1 assignee ·
-
Nonexistence of node_modules makes wrong pathsMay be free again @medikoo claimed this 3557 days ago, and no pull request is open. Open
medikoo/modules-webmake#54 · 3 comments · 1 assignee ·
-
Improve shell script arguments handlingMay be free again @medikoo claimed this 4723 days ago, and no pull request is open. Open
medikoo/modules-webmake#33 · 9 comments · 1 assignee ·
-
External sourcemapsMay be free again @medikoo claimed this 4851 days ago, and no pull request is open. Open
medikoo/modules-webmake#26 · 8 comments · 1 assignee ·
All issues in medikoo/modules-webmake
Similar issues
-
curriculum documentation quality
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
githubnext/gh-aw-workshop#5367 ·
Maintainers usually reply within 3 days
-
channels:add check:passed
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 4 days
-
beginner blocked
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hiero-ledger/hiero-sdk-js#4670 ·
Maintainers usually reply within 1 day
-
Media widget: selecting a paused player is ignored while another paused player holds an audio streamOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
area: editor complexity: easy impact: low status: triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ueberdosis/tiptap#8699 · 1 comment ·
Maintainers usually reply within 1 day