Fossil SCM

Improved cross-page caching of wikiedit/fileedit bundle, reducing those pages to a single request of 10-13k once cache is warm. Fixed non-bundled JS distribution of fileedit and wikiedit.

stephan 2020-08-24 22:46 misc-js-experiments
Commit 20c50cd1e5ca52be02cc98eb819b5a4efe798621501be6d4a36c541ba03c2038
--- src/builtin.c
+++ src/builtin.c
@@ -700,10 +700,21 @@
700700
** returns true. As a special case, if this is called more than once
701701
** in bundled mode, subsequent calls are a no-op.
702702
**
703703
** If the current JS delivery mode is *not* JS_BUNDLED then this
704704
** function is a no-op and returns false.
705
+**
706
+** Minor caveat: the purpose of emitting all of the fossil.XYZ JS APIs
707
+** at once is to reduce over-the-wire transfers by enabling cross-page
708
+** caching, but if there are other JS scripts pending via
709
+** builtin_request_js() when this is called then they will be included
710
+** in the JS request emitted by this routine, resulting in a different
711
+** script URL than if they were not included. Thus, if a given page
712
+** has its own scripts to install via builtin_request_js(), they
713
+** should, if possible, be delayed until after this is called OR the
714
+** page should call builtin_fulfill_js_requests() to flush the request
715
+** queue before calling this routine.
705716
*/
706717
int builtin_bundle_all_fossil_js_apis(void){
707718
static int bundled = 0;
708719
if(JS_BUNDLED == builtin_get_js_delivery_mode()){
709720
if(!bundled){
710721
--- src/builtin.c
+++ src/builtin.c
@@ -700,10 +700,21 @@
700 ** returns true. As a special case, if this is called more than once
701 ** in bundled mode, subsequent calls are a no-op.
702 **
703 ** If the current JS delivery mode is *not* JS_BUNDLED then this
704 ** function is a no-op and returns false.
 
 
 
 
 
 
 
 
 
 
 
705 */
706 int builtin_bundle_all_fossil_js_apis(void){
707 static int bundled = 0;
708 if(JS_BUNDLED == builtin_get_js_delivery_mode()){
709 if(!bundled){
710
--- src/builtin.c
+++ src/builtin.c
@@ -700,10 +700,21 @@
700 ** returns true. As a special case, if this is called more than once
701 ** in bundled mode, subsequent calls are a no-op.
702 **
703 ** If the current JS delivery mode is *not* JS_BUNDLED then this
704 ** function is a no-op and returns false.
705 **
706 ** Minor caveat: the purpose of emitting all of the fossil.XYZ JS APIs
707 ** at once is to reduce over-the-wire transfers by enabling cross-page
708 ** caching, but if there are other JS scripts pending via
709 ** builtin_request_js() when this is called then they will be included
710 ** in the JS request emitted by this routine, resulting in a different
711 ** script URL than if they were not included. Thus, if a given page
712 ** has its own scripts to install via builtin_request_js(), they
713 ** should, if possible, be delayed until after this is called OR the
714 ** page should call builtin_fulfill_js_requests() to flush the request
715 ** queue before calling this routine.
716 */
717 int builtin_bundle_all_fossil_js_apis(void){
718 static int bundled = 0;
719 if(JS_BUNDLED == builtin_get_js_delivery_mode()){
720 if(!bundled){
721
+2 -2
--- src/fileedit.c
+++ src/fileedit.c
@@ -1986,14 +1986,13 @@
19861986
"file/check-in combination are discarded.</li>");
19871987
CX("</ul>");
19881988
}
19891989
CX("</div>"/*#fileedit-tab-help*/);
19901990
1991
- builtin_request_js("sbsdiff.js");
19921991
if(!builtin_bundle_all_fossil_js_apis()){
19931992
builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
1994
- "storage", 0);
1993
+ "storage", "popupwidget", 0);
19951994
}
19961995
/*
19971996
** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
19981997
** used for dynamically toggling certain UI components on and off.
19991998
** Must come after window.fossil has been intialized and before
@@ -2000,10 +1999,11 @@
20001999
** fossil.page.fileedit.js. Potential TODO: move this into the
20012000
** window.fossil bootstrapping so that we don't have to "fulfill"
20022001
** the JS multiple times.
20032002
*/
20042003
ajax_emit_js_preview_modes(1);
2004
+ builtin_request_js("sbsdiff.js");
20052005
builtin_request_js("fossil.page.fileedit.js");
20062006
builtin_fulfill_js_requests();
20072007
{
20082008
/* Dynamically populate the editor, display any error in the err
20092009
** blob, and/or switch to tab #0, where the file selector
20102010
--- src/fileedit.c
+++ src/fileedit.c
@@ -1986,14 +1986,13 @@
1986 "file/check-in combination are discarded.</li>");
1987 CX("</ul>");
1988 }
1989 CX("</div>"/*#fileedit-tab-help*/);
1990
1991 builtin_request_js("sbsdiff.js");
1992 if(!builtin_bundle_all_fossil_js_apis()){
1993 builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
1994 "storage", 0);
1995 }
1996 /*
1997 ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1998 ** used for dynamically toggling certain UI components on and off.
1999 ** Must come after window.fossil has been intialized and before
@@ -2000,10 +1999,11 @@
2000 ** fossil.page.fileedit.js. Potential TODO: move this into the
2001 ** window.fossil bootstrapping so that we don't have to "fulfill"
2002 ** the JS multiple times.
2003 */
2004 ajax_emit_js_preview_modes(1);
 
2005 builtin_request_js("fossil.page.fileedit.js");
2006 builtin_fulfill_js_requests();
2007 {
2008 /* Dynamically populate the editor, display any error in the err
2009 ** blob, and/or switch to tab #0, where the file selector
2010
--- src/fileedit.c
+++ src/fileedit.c
@@ -1986,14 +1986,13 @@
1986 "file/check-in combination are discarded.</li>");
1987 CX("</ul>");
1988 }
1989 CX("</div>"/*#fileedit-tab-help*/);
1990
 
1991 if(!builtin_bundle_all_fossil_js_apis()){
1992 builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
1993 "storage", "popupwidget", 0);
1994 }
1995 /*
1996 ** Set up a JS-side mapping of the AJAX_RENDER_xyz values. This is
1997 ** used for dynamically toggling certain UI components on and off.
1998 ** Must come after window.fossil has been intialized and before
@@ -2000,10 +1999,11 @@
1999 ** fossil.page.fileedit.js. Potential TODO: move this into the
2000 ** window.fossil bootstrapping so that we don't have to "fulfill"
2001 ** the JS multiple times.
2002 */
2003 ajax_emit_js_preview_modes(1);
2004 builtin_request_js("sbsdiff.js");
2005 builtin_request_js("fossil.page.fileedit.js");
2006 builtin_fulfill_js_requests();
2007 {
2008 /* Dynamically populate the editor, display any error in the err
2009 ** blob, and/or switch to tab #0, where the file selector
2010
+3 -2
--- src/wiki.c
+++ src/wiki.c
@@ -1285,16 +1285,17 @@
12851285
CX("<h2>Wiki Name Rules</h2>");
12861286
well_formed_wiki_name_rules();
12871287
CX("</div>"/*#wikiedit-tab-save*/);
12881288
}
12891289
1290
- builtin_request_js("sbsdiff.js");
12911290
if(!builtin_bundle_all_fossil_js_apis()){
12921291
builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
1293
- "storage", "page.wikiedit", 0);
1292
+ "storage", "popupwidget", 0);
12941293
}
1294
+ builtin_request_js("sbsdiff.js");
12951295
builtin_request_js("fossil.page.wikiedit.js");
1296
+ builtin_fulfill_js_requests();
12961297
/* Dynamically populate the editor... */
12971298
style_emit_script_tag(0,0);
12981299
{
12991300
/* Render the current page list to save us an XHR request
13001301
during page initialization. This must be OUTSIDE of
13011302
--- src/wiki.c
+++ src/wiki.c
@@ -1285,16 +1285,17 @@
1285 CX("<h2>Wiki Name Rules</h2>");
1286 well_formed_wiki_name_rules();
1287 CX("</div>"/*#wikiedit-tab-save*/);
1288 }
1289
1290 builtin_request_js("sbsdiff.js");
1291 if(!builtin_bundle_all_fossil_js_apis()){
1292 builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
1293 "storage", "page.wikiedit", 0);
1294 }
 
1295 builtin_request_js("fossil.page.wikiedit.js");
 
1296 /* Dynamically populate the editor... */
1297 style_emit_script_tag(0,0);
1298 {
1299 /* Render the current page list to save us an XHR request
1300 during page initialization. This must be OUTSIDE of
1301
--- src/wiki.c
+++ src/wiki.c
@@ -1285,16 +1285,17 @@
1285 CX("<h2>Wiki Name Rules</h2>");
1286 well_formed_wiki_name_rules();
1287 CX("</div>"/*#wikiedit-tab-save*/);
1288 }
1289
 
1290 if(!builtin_bundle_all_fossil_js_apis()){
1291 builtin_emit_fossil_js_apis("fetch", "dom", "tabs", "confirmer",
1292 "storage", "popupwidget", 0);
1293 }
1294 builtin_request_js("sbsdiff.js");
1295 builtin_request_js("fossil.page.wikiedit.js");
1296 builtin_fulfill_js_requests();
1297 /* Dynamically populate the editor... */
1298 style_emit_script_tag(0,0);
1299 {
1300 /* Render the current page list to save us an XHR request
1301 during page initialization. This must be OUTSIDE of
1302

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button