turuslan / hacktimer Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
It works behind fine.
@ctubio, i want to contact you via email about https://github.com/ctubio/HackTimer , is c at rles-tub dot io your email?
Hello,
many thanks for this hack. But I would like to know how it actually works?
How does the webworker keep javascript timers going?
thank you for any help
Although this is a browser bug, many in-use versions of Chrome and possibly also Firefox and other browsers can GC web workers that don't have a reference in the window global scope.
This causes a lot of weird issues like everything appears to work - then suddenly no more messages from the web worker arrive.
When you open more tabs (Like 10 .. 20 or more), with each tab opening a new worker to implement HackTimer, there is an impact on system performance.
Is it possible to utilize SharedWorker to implement HackTimer?
We hope this will help achieve the same functionality across all the tabs using a single shared worker.
If possible can you please suggest the changes required?
Can you share your thoughts?
much like having this on npm, having this on bower would be great. along with this, having a tag would be awesome, since bower works on tags.
Unfortunately, it looks like Google may have patched around this wonderful webworker hack. (This hack fails in Google Chrome 54.0.2840.71
). Our team is investigating but we thought we'd submit an issue here too. If we discover the solution we'll be more than happy to contribute to this work.
When I'm using Firefox, there is a
TypeError: f[e.data] is undefined HackTimer.min.js:1:538
on the console.
But the functions is still working fine, do you know what it means?
Thanks!
'bower install hacktimer' results in a 'package hacktimer not found'
Hi, how to use it, can you give me an example? How can I currently replace my setInterval with libraries setInterval in reactjs?
Uncaught TypeError: Cannot read property 'innerHTML' of null
at unMinified.js:69
at Worker.worker.onmessage (HackTimer.js:134)
window.backspaceClock[index] = setInterval(function(){
str = document.getElementById(x[0].id).innerHTML;
The unMinified.js file is from my library .
I am using this library as my library relies heavily on timing. I have even mentioned your library in the Getting Started section.
Why is this happening when I do this: document.getElementById("intro").parentNode.removeChild(document.getElementById("intro"));
?
I have stopped the animation which stops all the loops, you can check out the unMinified.js file to see exactly what happens.
Shouldn't this library stop whatever is happening when whatever element is removed?
Thanks for such a great library!
Example:
setInterval (function (obj) {obj.x ++;}, {x: 12, y: 34})
Example:
setTimeout('alert("foobar!");', 1000);
Hot to use it.my project includes like:
<script src="bower_components/someLib/HackTimer.min.js"></script> <script src="bower_components/someLib/HackTimer.silent.min.js"></script> <script src="bower_components/someLib/HackTimerWorker.min.js"></script>not available (my english so bed)
Hi, I'm developing an HTML5 game (port of an old game, see http://ydkjs.eu or https://github.com/Mwyann/ydkjs) and i'm using this library to prevent the game from pausing when the tab loses focus. But I'm using a lot of timeouts and frequently the getFakeId would give the same ID to a couple of timeouts, leading to bugs obviously (callbacks not called properly).
For now I got around the problem by generating random fakeIds, that's maybe not very clean and maybe there's a 0.00001% chance of collision but that's enough for me :)
function getFakeId () {
var newId;
do {
newId = Math.floor(Math.random()*maxFakeId);
} while (fakeIdToCallback.hasOwnProperty (newId));
return newId;
}
If there's a better solution, I'd be glad to know it.
over time, if used for a really long time (8-36 hours) this causes a webpage to become incredibly slow. tested with and without on a project and the speed does not drop if hacktimer is not included.
HackTimer.silent.min.js is out of date since e11f3ed.
It would be nice if this source was made available via npm.
Under Safari, I see a situation where my 10hz interval timer is called ok while there is other activity in the page that creates other events of various kinds, however when there is a pause in the other events, all interval timers cease being called for 10 seconds or longer.
Then they resume, as though everything was just suspended.
Unfortunately I have not tried to make a tiny example of this happening :(
This should reduce memory usage and reuse existing (native) code.
Please add the following code before try/catch block which creates new Blob. In IE10 there is a problem when creating Blob (security error)
if(!/MSIE 10/i.test(navigator.userAgent)) {
try {
var blob = new Blob (["
var fakeIdToId = {};\
...
} catch (error) {
/* Blob is not supported, use external script instead */
}
}
Please pick a License (ideally MIT).
If you tell me which you want, I can do a PR.
When using HackTimer.js, In my browser's console a warning is logged :
Deferred long-running timer task(s) to improve scrolling smoothness. See crbug.com/574343.
And The whole website lags.
Any fix for this?
Using latest File.
(function(s) {
var w, f = {},
o = window,
l = console,
m = Math,
z = 'postMessage',
p = 0,
r = 'hasOwnProperty',
y = [].slice,
x = 'fail',
v = Worker;
v = Worker; <----
Worker is undefined, script crashes before hitting this check:
if (typeof(v) !== 'undefined') {
@line 51:
callback.call (window);
It seldom happens to some people, I wonder why?
And it's a great job, thank you very much.
@turuslan
See karma-runner/karma#1568
Karma is a perfect candidate for HackTimer, but I still see throttling in background tabs.
Any help you can offer would be great.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.