A Better setTimeout

If you’ve ever used JavaScript’s setTimeout and setInterval methods. you’ve probably found them just a bit … inadequate.

  • Both return an integer rather than an actual handle.
  • If you’re using both setTimeout and setInterval, you have to remember whether the integer value is a timeout or an interval in order to call the appropriate clearXXX method.

Continue reading

Dojo AMD incorporating third party scripts

So, you’ve started using RequireJS or you’ve upgraded to the latest version of Dojo and have converted your web application over to Asynchronous Module Definition (AMD) loading. However, your code still depend on some third party non-AMD scripts. Can and should these scripts be incorporated as AMD dependencies? By “non-AMD” I mean the third party scripts which are not wrapped in a define() or require().

define([ /* ... */], function(){
   //... body of third party script

The most important question to answer is: Can you modify the code?

Continue reading