Loading local javascript files via frontmatter doesn’t work for me as it seems (js: /js/chart.js).
Would be just “nice to have”. But this of course is not a problem at all.
What I see is: when using two charts via shortcode there is no additional http request for loading the (locally stored) chart.js script - but the CPU time is much higher.
Beside that the chart via shortcode is not responsive out of the box in comparison to the basic implementation.
Can I avoid multiple script loadings for multiple charts when loading the chart.js script once via content file? As far I have tested this should work.
I guess I just need to load the javascript once and then create a new canvas for every chart.
If it worked like this I wouldn’t see advantages of the shortcode implementation by shen-yu in 2023 no more.
Thank you very much!
I’ll keep on going with the regular method I think.
But good to have that documented for others who are searching for these keywords.
I checked the pagespeed today.
I inserted 6 radar charts into one post to illustrate 4 different properties.
The local file delivery of chart.js adds 63kb of zipped data transfer.
The calculation of all charts adds in sum up additional 200 ms of CPU time.
For me it’s fine for that amount of charts enriching the other content.
Loading time for the whole document now takes ~1.0s for first view. I’m fine with that
Loading from a CDN is not any more „regular“ than loading from your server. But the CDN method might create GDPDR issues similar to using Google fonts does.