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 6204743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:09:00+00:00 2026-05-24T05:09:00+00:00

I’m planning on writing some code for encrypting files in javascript locally. For large

  • 0

I’m planning on writing some code for encrypting files in javascript locally. For large files and large key sizes, the CPU usage (naturally) is pretty high. In a single script design, this often hangs the browser until the task is complete.

In order to improve responsiveness and allow users to do other things in the mean time I want to try make the script ‘friendlier’ to the user’s PC. The encryption process will be reading a file as a binary string and then encrypting the string in chunks (something like 1KB/chunk – needs testing). I want to try and user HTML5-based workers to make the whole thing as incremental as possible. Something like:

  1. Spawn worker
  2. Send worker a binary data chunk
  3. Worker completes encryption, passes back new chunk
  4. Worker dies.

This might also help with multicore processors, by having multiple workers alive at once.

Anyway, has anybody looked at deliberately slowing down a script in order to reduce CPU usage? Something like splitting the worker’s encryption task into single operations, and introducing a delay between them.

Interval timer callback every 100ms (example).

Is worker busy?
Yes – Wait for another interval
No – Start encrypting the next letter

Advice/thoughts?

Does anyone have experience using workers? If you seperate the main UI from intensieve work by making it a worker, does the responsiveness increase?

  • 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-05-24T05:09:01+00:00Added an answer on May 24, 2026 at 5:09 am

    This doesn’t utilize anything HTML5, but here’s an example for calling a function every N milliseconds, assuming you can determine an appropriate wait time. Basically, I’m trying to help you by showing you a way to enforce stalling some amount of time before doing more processing.

    function doSomething(){
       clearTimeout(timeout);
       // do your "expensive" processing
       // ...
       // decide the job is done and return here or else
       // call doSomething again in sleepMS milliseconds
       timeout = setTimeout(doSomething,sleepMS);
    }
    var timeout;
    var sleepMS = 1000;
    
    
    doSomething();
    

    EDIT

    changed last line from

    var timeout = setTimeout(doSomething,1000);
    

    to just this

    doSomething()
    

    EDIT 2

    Changed 1000 to sleepMS in setTimeout call, duh 🙂

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

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.