Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:37:51+00:00 2026-06-12T08:37:51+00:00

The loading times of my processingjs webpage are getting pretty hairy. How can I

  • 0

The loading times of my processingjs webpage are getting pretty hairy. How can I precache the compilation of processing to javascript?

It would be acceptable for my application to compile on first entering the webpage (maybe keeping the result in the local store?) and then reuse the compilation on subsequent loads.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:37:52+00:00Added an answer on June 12, 2026 at 8:37 am

    There’s two ways to drive down load time as experienced by the user. The first is using precompiled sketches, which is relatively easy: github repo, or even just download the master branch using github’s download button (https://github.com/processing-js/processing-js), and then look for the “./tools/processing-helper.html” file. This is a helper page that lets you run or compile sketches to the JavaScript source that Processing.js uses. You will still need to run this alongside Processing, since it ties into the API provided, but you can use the “API only” version for that. Take the code it generates, prepend “var mySketch = “, and then do this on your page:

    <script src="processing.api.js"></script>
    <script>
    function whenImGoodAndReady() {
      var mySketch = (function.....) // generated by Processing.js helper
      var myCanvas = document.getElementById('mycanvas');
      new Processing(myCanvas, mySketch);
    }
    </script>
    

    Just make sure to call the load function when, as the name implies, you’re ready to do so =)

    The other is to do late-loading, if you have any sketches that are initially off-screen.

    There’s a “lazy loading” extension in the full download for Processing.js – you can include that on your page, and it will make sketches load only once they’re in view. That way you don’t bog down the entire page load.

    Alternatively, you can write a background loader that does the same thing as the lazy loading extension: turn off Processing.init, and instead gather all the script/canvas elements that represent Processing sketches, then loading them on a timeout using something like

    var sketchList = [];
    
    function findSketches() {
      /* find all script/canvas elements */
      for(every of these elements) {
        sketchList.append({
          canvas: <a canvas element>,
          sourceCode: <the sketch code>
        });
      }
      // kickstart slowloading
      slowLoad();
    }
    
    function slowLoad() {
      if(sketchList.length>0) {
        var sketchData = sketchList.splice(0,1);
        try {
          new Processing(sketchData.canvas, sketchData.sourceCode);
          setTimeout(slowLoad, 15000); // load next sketch in 15 seconds
        } catch (e) { console.log(e); }
      }
    }
    

    This will keep slow-loading your sketches until it’s run out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I measure the following points Server Processing Time Page Loading Time Page
Ok, in my app there are times when loading the DataGridView can take a
Emulating multithreading by loading a DLL multiple times (it's designed for this). Since LoadLibrary()
I am having issues with loading external javascript using JQuery. Every time when I
Noticing a long delay in server processing time. The application environment is: Apache2 Ubuntu
The 304 Not Modified processing message is occurring with every JavaScript (.js) file type
Server loading static resources too slowly - what server optimizations can I make? Images
I have come across an issue when loading different NSImages repeatedly in an application
PROBLEM Loading fixtures for large text fields crashes the fixture-processing process and often even
I am currently trying to improve website loading times and I am using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.