Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A very good technique to help minifiers, is to pass variables into a self invoking function:</p> <pre><code>(function(window, document, $, undefined) { // all of your application logic goes in here }(window, window.document, jQuery)); </code></pre> <p>A minifier will then create shortcuts for the arguments, like <code>a, b, c, d</code>.</p> <pre><code>(function(a, b, c, d) { }(window, window.document, jQuery)); </code></pre> <p>Now, <code>window</code>, <code>document</code> and <code>jQuery</code> (if it's used) and the <code>undefined value</code> are accessed quite often normally. This will help to decrease the filesize even more.</p> <p>A few nice Javascript shortcuts, are described in <a href="http://typeofnan.blogspot.com/2010/11/about-javascript-shortcuts-trickery.html" rel="noreferrer">this <strong>article</strong></a>.</p> <p>For instance, use <code>~~</code> instead of <code>Math.floor()</code>.</p> <p><strike></p> <pre><code>var floored = Math.floor(55.2115); // = 55 </code></pre> <p></strike></p> <pre><code>var floored = ~~(55.2115); // = 55 </code></pre> <hr> <p>Another really neat thing is, that almost all Javascript interpreters convert numbers for you. For instance, we want to have a <code>setTimeout</code> which fires after 3 minutes. Instead of doing it like</p> <pre><code>setTimeout(function() { }, 180000); </code></pre> <p>or <code>60 * 3 * 1000</code>, we can just call:</p> <pre><code>setTimeout(function() { }, 18e4); </code></pre> <p>Which probably makes much more sense, on much bigger numbers, but anyway :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload