Sleep-enabled JavaScript-self-compiling JS engine _javascript Tips

Source: Internet
Author: User
That is why the function is so needed, but why does JS not provide such a function?

At present browsers are in the UI thread parsing JS, for example, Firefox browser, I recompile the JS engine, and in the JS alarm added to the sleep method, the method calls the C-language thread sleeping function.
Attaches a method to object, the method signature is sleep (), no parameters. Default hibernate for 1 seconds, if you call this function in JS, the browser UI interface will be blocked.


In addition, if your JS function has a dead loop, the browser JS resolution will detect the JS implementation timeout will remind you whether to terminate the execution of this page of JS.
Finally provide a new compiled JS engine, they replace Firefox under the JS engine can be.

Then you can write a section of JS to play, such as "Testsleep". Sleep (); Because I was added in object, you can call this function on any JS object.

Instructions for use:
The main requirement is that site visitors need to install your customized browser.
You're not going to publish your own Firefox client, if your project really needs it.
We must specify our own browsers as simple as requiring users to have a flash plugin installed.

Annex: Firefox_js.rar
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.