processing / processing/p5.js-website

CodeFrame does not cache p5 library in service worker or browser cache on Chromium

Open
#213 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Priority: high
Dominant language
MDX
Stars
96
Forks
322
Avg merge
5d 22h
Merged PRs (30d)
8

Description

Chromium browsers do not cache the p5 library used for examples. This is a limitation on the use of iframes with a srcdoc attribute on Chromium as documented here. As a result, pages like the arc() reference download the p5 library for each example. This happens regardless of service worker scope, origin, etc as far as I can tell. This does not happen on Firefox or Safari.

Screenshot 2024-04-22 at 2 29 45 PM

Some solution using iframe and srcdoc may exist that I do not see but afaik there are two possible approaches from here:

  1. Generate HTML files to serve for the src attribute of the iframe ala _arc_reference_example_1.html. This is similar to what happens on the current p5 sites's example pages.
  2. Make the CodeFrame component use p5 instance mode to render the canvas directly into the body without an iframe/document wrapper. This is how the current p5.js site handles reference sketches.

I believe that 2 is cleaner but I am open to alternatives. I think that the equivalent code from the current p5 website is here.

Potentially useful links:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the CodeFrame component and the current p5.js website's src/assets/js/render.js, then reproduce the arc() reference example in Chromium. Compare the iframe/srcdoc approach with the instance-mode approach described in the issue. Done means the p5 library is not downloaded separately for every example in Chromium.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, performance, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.