-
Notifications
You must be signed in to change notification settings - Fork 20
Preprocessing DOM when running make #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Avoid setting the text content when the split is unsuccessful
|
Just want to add that this is the only javascript code that I've ever written so if anything looks wrong then it probably is :) |
We don't have a test suite yet, so maybe good time to create a self-contained one under the /example directory. |
|
and I suppose coqdocjs-static should be copied rather than linked before merging. |
Update Makefile to use coqdocjs-static to preprocess the html files Update Makefile and fix a typo in the function name Add environment variables for coqdocjs static Refactor to use for loops Fix preprocess in index.js Parallelize the preprocessing Remove unneeded config.js file for static build Add log messages Typo Fix bug in makefile Revert back to the old efficient implementation Update package lock Remove the extra /
I can create an example. It would also be helpful if one of the maintainers can double-check that the output looks right.
I have inlined coqdocjs-static in the latest commit. I moved the logic in By default, The only backward compatibility issue is the use of ES6 modules. To test the files locally, you must start a local web server or the browser will complain about CORS, although according to the information I can gather online, that's a somewhat reasonable behavior. |
|
I'm having second thoughts about using modules to split up the preprocessing logic because not being able to directly run Perhaps we can use a perl or bash script to manually stitch the files together so we can still use the more lenient classic scripts? |
|
So I think a straightforward, backward-compatible solution could be structured like this:
The only issue is that if the If it's considered too big of a change, I'd happily maintain my separate fork and pull from the upstream every once in a while. I don't think many people run into the same performance issue that I did, and it's probably not the best practice to have files with >3000LoC code anyways |
Note that this pull request is not in an ideal shape to be merged just yet as it requires a
node.jsinstallation.The problem that the PR addresses
coqdocjs.js now contains code that processes the html file when it's loaded by the web browser. However, these operations are quite slow for large files, especially
foldProofs, which currently does two things:proofThe first operation is quite slow. This file, for example, makes firefox hang for around 10 seconds before the page becomes responsive.
My solution
The good news is that the overhead of the first step can be done by preprocessing the html files produced by coqdoc when running
make. That's exactly what this PR does.I ported all the code that preprocesses the html file into a separate repository coqdocjs-static. The code from
config.jsandpreprocess.jsare pretty much copy/pasted from thecoqdocjs.The
index.jsscript takes as an input the path to an html file and perform all operations fromrepairDom,replInTextNodes,foldProofsto the dom (except for the code that registers events) before printing the result to stdout (or overwrites the input file with the--inplaceflag).The static branch of my fork of coqdocjs includes
coqdocjs-staticas a submodule. The makefile callsindex.jsfromcoqdocjs-staticon all generated html files. Thecoqdocjs.jsis modified so it only registers events.Benchmark
Here are the benchmark results of loading the
fp_red.htmlfile before and after the change.Before:

After:

Todos
Ideally, I'd like to merge the code from the
coqdocjs-staticrepo here and make the static generation a feature that is disabled by default, but can be optionally opted in if the input files are large. The static html generator requires anode.jsandnpminstallation, whereascoqdocjscurrently doesn't require any dependency at all.I can probably do it with a few Makefile flags, but I don't know if there are a set of tests I can run to make sure nothing breaks.
UPDATE: I managed to add the static preprocessor in a (hopefully) backward compatible way, with the only downside being the introduction of ES6 modules, which can cause problems when browsing the files locally (see https://stackoverflow.com/questions/46992463/es6-module-support-in-chrome-62-chrome-canary-64-does-not-work-locally-cors-er?rq=1)