|
Lumpy posted:You will wonder why you used prototype for so long. It's not too bad, it's just that jQuery is a lot less cluttered and all the APIs have a standard form. jQuery certainly has more progress these days than Scriptaculous.
|
# ¿ Dec 31, 2009 03:47 |
|
|
# ¿ Apr 29, 2024 09:36 |
|
RussianManiac posted:is there any sycnrhonizatino in javacsript? Do most browsers implement pure user level threads for JS or do some of them actually might execute in parallel? Check out HTML 5 or Gears for threading support, http://code.google.com/apis/gears/api_workerpool.html
|
# ¿ Jan 1, 2010 10:02 |
|
RussianManiac posted:What are the event callbacks for when the javascript just loads Common hack is to use a <script> element at the end of the page, otherwise use this: http://api.jquery.com/ready/
|
# ¿ Jan 22, 2010 09:00 |
|
Server sent events would be nicer for unidirectional communication, but JSON over XHR is the most convenient.
|
# ¿ May 26, 2014 15:19 |
|
That's quite nice, a jQuery layer replicating web animations. Wonder what the performance is like at larger scale with the chaining mechanism. Using RAF tends to work better than CSS transitions though if you want 60fps.
|
# ¿ May 28, 2014 15:16 |
|
Reading OK - FileReader API, writing requires a round-trip. Also, there is AppCache and IndexedDB which may be of use.
|
# ¿ Jun 7, 2014 20:12 |
|
Strong Sauce posted:It's not recommended to use AppCache. Completely unusable. http://alistapart.com/article/application-cache-is-a-douchebag You just have to not be dumb, read the follow up article http://flailingmonkey.com/application-cache-not-a-douchebag. Using AppCache in an iframe works pretty well.
|
# ¿ Jun 8, 2014 22:08 |
|
The Insect Court posted:You could take a look at http://google.github.io/tracing-framework/index.html if Chrome's default dev tools aren't extensive enough. Nice although appears nothing much more than a search front end to the existing chrome://tracing data. The biggest issue is usually the fault is with GC and there is nothing one can do with that outside of closed environments. There is command line flag to enable an API to manually initiate GC and you can custom build chrome to increase the frequency of GC.
|
# ¿ Sep 14, 2014 11:59 |
|
That seems a little problematic on scalability, you can capture standard console logging in Chrome or Firefox under Linux in its parent console. The biggest problem I found recently is that logging objects, e.g. console.log ("log this:", object) keeps a reference on the object until the log is wiped from memory! Incredibly dangerous implementation for long running pages.
|
# ¿ Jan 9, 2015 02:00 |
|
<head> doesn't execute scripts until fully loaded, hence the inlining of scripts for faster execution. The use of RAF is for at least one render, i.e. a pseudo-DOMReady() event handler. setTimeout(0) is always useful as a yield function as Javascript is a co-operative environment in a single thread.
|
# ¿ Mar 2, 2015 19:45 |
|
Space Whale posted:Is there already some sort of API I can call to do this or is this going to be a case of roll-your-own with storing (x,y), drawing to the page, calculating distance to the right side of the page, etc? For a start you need to work with a resolution independent co-ordinate system and test out what is going to be legible on all target devices. A popular project has been implemented fridge magnets for letters and letting everyone play with them. I think I even posted one here like ten years ago. MrMoo fucked around with this message at 00:49 on Mar 5, 2015 |
# ¿ Mar 5, 2015 00:45 |
|
Odette posted:Here's my lovely npm package, how can I improve it? Any glaring errors or bad implementations of ... anything? The function names getStory() and getInfo() are not technically accurate but at least they are short. MrMoo fucked around with this message at 16:27 on Nov 25, 2015 |
# ¿ Nov 25, 2015 16:22 |
|
Raskolnikov2089 posted:Working with API rate limits, is wrapping my requests in a setTimeout a bad way to go about it? Not many APIs available, one can add requestIdleCallback to better integrate with animation if you are not calling in a service worker.
|
# ¿ Feb 19, 2016 15:21 |
|
I've done the second one once because it was easier to read than !OtherCondition, the former I can only guess is from some crazy bug hunting session where every execution path "must be defined", i.e. dangling else statements and fruity indentation causing the programmer problems.
|
# ¿ May 9, 2016 20:34 |
|
npm is the package manager for node.js thus some sort of " JavaScript programmers" comment, a.k.a. leftpad.
|
# ¿ May 12, 2016 01:14 |
|
I cannot remember if it still works but add a desktop shortcut to Chrome with "--disable-web-security" on the command line. Don't forget the OPTIONS pre-flight request if using a proxy, e.g. code:
code:
MrMoo fucked around with this message at 21:03 on May 31, 2016 |
# ¿ May 31, 2016 20:55 |
|
Subjunctive posted:Please, no. This is super dangerous. If you accidentally end up browsing the internet with that flag set you are incredibly vulnerable. The flag's name is not overstated. Reuters API docs used to recommend it after I pointed out a defect due to security changes in Chrome, now it is a little better: quote:*Warning* Your browser is detected as "Chrome". If you are accessing this help system directly from file(s), please make sure to use the Chrome parameter --allow-file-access-from-files (eg. “<*path*>/chrome.exe" --allow-file-access-from-files) . If this parameter is not used, please use Classic Documentation or use a different browser.
|
# ¿ Jun 1, 2016 19:46 |
|
Analytic Engine posted:window.performance Things are getting better too: https://www.w3.org/TR/navigation-timing-2/
|
# ¿ Oct 6, 2016 18:20 |
|
What does Google docs use for screenshots in the help system, is it something like dom-to-image?
|
# ¿ Mar 1, 2017 16:27 |
|
Isn't the crappy situation of browsers not supporting ECMAScript import but everything else does?
|
# ¿ Apr 10, 2017 22:33 |
|
meinstein posted:Edit: A large amount of "professional" JavaScript is written by people that don't know what they're doing, and are flying by the seat of their pants cobbling together half-understood examples from Stack Overflow. If you read those two you'll be streets ahead. I've been skimming around on debounce and throttle functions and there are many articles on the topic. Common theme was not to implement your own because libraries are awesome and peer reviewed by Trump himself and so they must be great. So I picked up Lodash and tried their throttle() API and guess what, it is fundamentally flawed and broken, spent this morning rewriting it to be less brain dead but still shines of authors trying too hard for a relatively simple requirement. quote:Creates a throttled function that only invokes func at most once per every wait milliseconds. So the authors decide to implement the rate limit tracking on the incoming calls to the throttle rather than the actual function that is supposed to be throttled. It is just so weird when you attach it to something graphical.
|
# ¿ Jun 8, 2017 00:38 |
|
Jabor posted:I'm not sure I understand the objection. How are you using it? What are you expecting to happen, and how is this different from what it actually does? Looks like it has been logged before, they are impressively zealous on closing issues in their tracker: https://github.com/lodash/lodash/issues/3051 I used it to throttle updates to a Polymer field which is tied to a display item on the page. The Lodash implementation causes the item to randomly double update. This is my version: MrMoo fucked around with this message at 18:01 on Jun 8, 2017 |
# ¿ Jun 8, 2017 17:36 |
|
"Professional integrator" version, i.e. I copied the debounce() implementation and replaced all Lodash functions with standard ECMA functions where I could be bothered (no exception on function parameter not being a function) and fixed it by using lastInvokeTime instead of lastCallTime for rate checks, everything else as ugly as it was. http://ahyoomee.miru.hk/donald/throttle/throttle.js
|
# ¿ Jun 8, 2017 19:12 |
|
I think they want a PR and a contributor agreement, I haven't decided what to do with it yet, it's just in a branch for testing a specific data flag. It's F/OSS so good luck stealing it.
|
# ¿ Jun 8, 2017 20:21 |
|
Samples are CC0 apparently, core base is MIT. I wonder what classifies as substantial though:quote:The above copyright notice and this permission notice shall be
|
# ¿ Jun 8, 2017 20:53 |
|
The classic JSON.stringify(a) === JSON.stringify(b) is still valid for comparing objects. With arrays there is room for interpretation of what equality means, the Polymer project has this issue when detecting changes in an array: https://www.polymer-project.org/1.0/docs/devguide/model-data
|
# ¿ Jun 16, 2017 18:32 |
|
Made me remember this: https://twitter.com/ID_AA_Carmack/status/844885670732685313
|
# ¿ Jun 16, 2017 19:18 |
|
geeves posted:The correct answer is, "Who ever wrote that should be defenestrated immediately." Or just: "so you need a new team lead then?"
|
# ¿ Jun 21, 2017 02:19 |
|
Anyone recommend a non-terrible library for extracting the background colour of an image? I have found a few that are poorly written but generally rely on a third party to do the actual logic, e.g. modified median cut quantization. It's not simply the dominant colour of the entire image though as I'm dealing with logos with mainly transparent backgrounds which would produce an incorrect result. So I can create a canvas taking the full available height, center the actual logo and backfill with yellow. Similar example: MrMoo fucked around with this message at 18:07 on Aug 15, 2017 |
# ¿ Aug 15, 2017 18:01 |
|
Some really inconvenient logos to work with, I ended up scanning alternating pixels on the top second two lines and bottom last-but one pair of lines and comparing the values to prevent breaking on a asymmetric gradient. This is functional for logos with solid colours otherwise a more astute algo is required. JavaScript code:
MrMoo fucked around with this message at 21:43 on Aug 15, 2017 |
# ¿ Aug 15, 2017 21:39 |
|
Normally the createImageBitmap(blob) promise will do that.
|
# ¿ Aug 17, 2017 17:06 |
|
Joda posted:Not sure if this is the right thread to ask this, but if I compile some C++ to webassembly and am using multithreading (e.g. std::thread, std::future etc.) will that execute on multiple threads, or is webassembly stuck with one thread like JS? If so, to get parallel execution when compiling with gcc for native execution I have to add the compiler flag -pthread to get mutexes and such to act like they're supposed to, do I have to do something similar for webassembly compilation? Multi-threading is supposed to be landing this https://wasmdash.appspot.com Kinda meh page: https://github.com/WebAssembly/threads MrMoo fucked around with this message at 20:27 on Oct 9, 2017 |
# ¿ Oct 9, 2017 19:40 |
|
You could probably just use WebAssembly now and dump to a JS string.
|
# ¿ Nov 13, 2017 23:46 |
|
ArcticZombie posted:With synchronous XHR being deprecated, is there a go to method if a request absolutely must be synchronous? code:
|
# ¿ Nov 18, 2017 03:51 |
|
|
# ¿ Nov 18, 2017 20:32 |
|
Socket.io does that for you, fundamentally WebSockets are quite different in the browser to Node.JS as one yields errors synchronously and the other asynchronously. It sucks.
|
# ¿ Jan 22, 2018 06:50 |
|
I found this today and had to nudge it a bit because I was compiling to ES2015 and it was breaking. A Promise wrapper that performs retries inside another Promise.JavaScript code:
Use it something like this: JavaScript code:
|
# ¿ Jun 14, 2018 01:26 |
|
Roadie posted:Use p-retry instead. It has better coverage for various edge cases including being able to abort the retries from the outside. Probably need something with a configurable increasing delay and randomization, node-promise-retry has that.
|
# ¿ Jun 14, 2018 05:06 |
|
TheFluff posted:Just use the async library for everything. It does everything you could possibly want to do with asynchronous functions and is far better than anything else I've seen. It lets you run asynchronous tasks in series, in parallel, or in parallel with a limit on concurrent tasks. It supports asynchronous iterators for all the usual suspects (map, filter, reduce, etc) as well as asynchronous control flow. async.auto is the greatest thing to happen to Javascript since the arrow function. Nice, but weird all the callbacks instead of using Promise chains. 2 steps forward, 2 steps back kind of thing.
|
# ¿ Jun 14, 2018 14:44 |
|
|
# ¿ Apr 29, 2024 09:36 |
|
Although it is almost one liner normally anyway:JavaScript code:
|
# ¿ Jun 14, 2018 15:42 |