Comments (8)
Since v0.1.4 ReLaXed is much faster, and also gives a better breakdown of it's different rendering steps, which should make it easier to optimize particular cases in the future. Turns out that mathjax rendering was also a bottleneck so it is now optional and replaceable by the faster Katex.
from relaxed.
Great idea.
Here are some of my thoughts and ideas:
page.eval
with checking for documentReady
or similar might be also a solution. Never checked for the idle status.
H(M)R is typically faster (that's what we do in React and other UI frameworks).
from relaxed.
The waitFor
in the line linked is actually equivalent to a page.eval from what I understand.
from relaxed.
I'm not sure that Hot Reload would make a /massive/ difference, the time spent (for me at least) is printing the PDF, not generating the HTML.
Waiting until 'networkidle2' does seem to add an extra second to the PDF printing. Is this only needed if remote images/styles are being requested? If so could it be checked when creating the HTML with Cheerio and if there are any remote urls in the content, then set that option, otherwise ignore it?
Avg time ins seconds:
PDF Disabled | PDF Enabled | PDF Enabled - no networkidle2 | |
---|---|---|---|
Small (1 page) | 0.10 | 1.19 | 0.30 |
Large (81 pages) | 0.65 | 3.67 | 2.84 |
A quick test on a .pug file containing pug syntax/markdown and scss styling:
large.pug
- 5390 lines
- 81 pages
PDF Output disabled
[10:51:59] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/large.pug doc/large.pdf --watch assets --temp tmp
Watching src/large.pug and its directory tree.
Processing detected change in /large.pug...
... done in 1.13s
Processing detected change in /large.pug...
... done in 0.76s
Processing detected change in /large.pug...
... done in 0.59s
Processing detected change in /large.pug...
... done in 0.60s
Processing detected change in /large.pug...
... done in 0.53s
Processing detected change in /large.pug...
... done in 0.58s
Processing detected change in /large.pug...
... done in 0.60s
Processing detected change in /large.pug...
... done in 0.58s
Processing detected change in /large.pug...
... done in 0.53s
Processing detected change in /large.pug...
... done in 0.55s
PDF Output enabled
[10:54:26] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/large.pug doc/large.pdf --watch assets --temp tmp
Watching src/large.pug and its directory tree.
Processing detected change in /large.pug...
... done in 5.16s
Processing detected change in /large.pug...
... done in 3.47s
Processing detected change in /large.pug...
... done in 3.50s
Processing detected change in /large.pug...
... done in 3.51s
Processing detected change in /large.pug...
... done in 3.50s
Processing detected change in /large.pug...
... done in 3.43s
Processing detected change in /large.pug...
... done in 3.45s
Processing detected change in /large.pug...
... done in 3.49s
Processing detected change in /large.pug...
... done in 3.52s
Processing detected change in /large.pug...
... done in 3.68s
PDF Output enabled (without {waitUntil: 'networkidle2'})
[10:59:57] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/large.pug doc/large.pdf --watch assets --temp tmp
Watching src/large.pug and its directory tree.
Processing detected change in /large.pug...
... done in 3.74s
Processing detected change in /large.pug...
... done in 2.88s
Processing detected change in /large.pug...
... done in 2.75s
Processing detected change in /large.pug...
... done in 2.74s
Processing detected change in /large.pug...
... done in 2.65s
Processing detected change in /large.pug...
... done in 2.73s
Processing detected change in /large.pug...
... done in 2.73s
Processing detected change in /large.pug...
... done in 2.76s
Processing detected change in /large.pug...
... done in 2.69s
Processing detected change in /large.pug...
... done in 2.70s
small.pug
- 22 lines
- 1 page
PDF Output disabled
[15:13:54] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/small.pug doc/small.pdf --watch assets --temp tmp
Watching src/small.pug and its directory tree.
Processing detected change in /small.pug...
... done in 0.35s
Processing detected change in /small.pug...
... done in 0.10s
Processing detected change in /small.pug...
... done in 0.09s
Processing detected change in /small.pug...
... done in 0.13s
Processing detected change in /small.pug...
... done in 0.15s
Processing detected change in /small.pug...
... done in 0.09s
Processing detected change in /small.pug...
... done in 0.12s
Processing detected change in /small.pug...
... done in 0.12s
Processing detected change in /small.pug...
... done in 0.09s
Processing detected change in /small.pug...
... done in 0.12s
PDF Output enabled
[15:14:53] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/small.pug doc/small.pdf --watch assets --temp tmp
Watching src/small.pug and its directory tree.
Processing detected change in /small.pug...
... done in 1.19s
Processing detected change in /small.pug...
... done in 1.18s
Processing detected change in /small.pug...
... done in 1.18s
Processing detected change in /small.pug...
... done in 1.19s
Processing detected change in /small.pug...
... done in 1.18s
Processing detected change in /small.pug...
... done in 1.22s
Processing detected change in /small.pug...
... done in 1.18s
Processing detected change in /small.pug...
... done in 1.20s
Processing detected change in /small.pug...
... done in 1.21s
Processing detected change in /small.pug...
... done in 1.21s
PDF Output enabled (without {waitUntil: 'networkidle2'})
[15:17:13] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/small.pug doc/small.pdf --watch assets --temp tmp
Watching src/small.pug and its directory tree.
Processing detected change in /small.pug...
... done in 0.80s
Processing detected change in /small.pug...
... done in 0.24s
Processing detected change in /small.pug...
... done in 0.23s
Processing detected change in /small.pug...
... done in 0.26s
Processing detected change in /small.pug...
... done in 0.28s
Processing detected change in /small.pug...
... done in 0.26s
Processing detected change in /small.pug...
... done in 0.23s
Processing detected change in /small.pug...
... done in 0.25s
Processing detected change in /small.pug...
... done in 0.26s
Processing detected change in /small.pug...
... done in 0.21s
from relaxed.
@benperiton awesome, that's the kind of data I am after. The question is what happens for short files. In that case, I expect the processing time to be much less, and the networkidle2 overhead increases it severalfold.
from relaxed.
@Zulko I've added some numbers for a small.pug file. (and a little avg table)
from relaxed.
Awesome, so yeah, for small pug files, going from 1.20 to 0.20 seconds would be a great improvement, almost like real-time rendering. Very useful when you are crafting a leaflet or any otherwise complex one-page document.
from relaxed.
Yea, there's quite a big jump! It does seem that the first run is always slower than the rest, not quite sure why that is, it does skew the average slightly but potentially some low hanging fruit to speed it up overall.
from relaxed.
Related Issues (20)
- ReLaXed doesn't work on WSL HOT 5
- this._initPDFReader is not a function and ERR_FILE_NOT_FOUND with masterToPDF HOT 3
- masterToPDF fails on second run HOT 1
- Add support for running ReLaXed directly in NodeJS, without CLI HOT 8
- Passing JSON object to ReLaXed: wiki needs to be updated! HOT 5
- Documentation for 'headElements' says 'htmlHead' HOT 1
- Implementation of Knuth & Plass Algorithm
- [Question] Only last page footer text is showing with color. Other page footer text is existing but transparent. HOT 2
- Load JSON and listen to changes? HOT 3
- Using relaxedjs as a node module in AWS and run once HOT 2
- Vegalite SVG render broken HOT 6
- Hj
- Failed to install Relaxed on Ubuntu18.04 on EC2 HOT 1
- How to make pdf pages in horizontal orientation? HOT 1
- Any Ideas for better Debugging Support in the Browser? HOT 4
- Fix security vulnerabilities HOT 1
- Is relaxedjs still under active development? HOT 6
- Math Typeface Not Rendering Properly HOT 1
- Unable to use ReLaXed with Node v16 HOT 3
- Please publish current version (0.2.5) to npmjs.com HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relaxed.