Skip to content

Instantly share code, notes, and snippets.

@gre
Last active November 12, 2021 15:20
Show Gist options
  • Save gre/9364718 to your computer and use it in GitHub Desktop.
Save gre/9364718 to your computer and use it in GitHub Desktop.

Revisions

  1. gre revised this gist Mar 5, 2014. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,6 @@
    JS1K template
    JS1K Boilerplate
    ---

    - Fork this gist
    - Clone your fork (with git)
    - Push your code to it
    - Share it to people / show it running with **http://bl.ocks.org/[yourusername]/[gistid]**

    Build tools
    ---

    @@ -26,6 +21,13 @@ It will give you some stats:
    5739 source.js
    ```

    Suggestion
    ---
    - Fork this gist
    - Clone your fork (with git)
    - Push your code to it
    - Share it to people / show it running with **http://bl.ocks.org/[yourusername]/[gistid]**

    ---

    DWTFYW license
  2. gre revised this gist Mar 5, 2014. 2 changed files with 1 addition and 2 deletions.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ JS1K template
    - Fork this gist
    - Clone your fork (with git)
    - Push your code to it
    - Share it to people / show it running with **http://bl.ocks.org/<yourusername>/<gistid>**
    - Share it to people / show it running with **http://bl.ocks.org/[yourusername]/[gistid]**

    Build tools
    ---
    1 change: 0 additions & 1 deletion source.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    // Template of source code
    // Following code is just a suggestion

  3. gre created this gist Mar 5, 2014.
    32 changes: 32 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    JS1K template
    ---

    - Fork this gist
    - Clone your fork (with git)
    - Push your code to it
    - Share it to people / show it running with **http://bl.ocks.org/<yourusername>/<gistid>**

    Build tools
    ---

    Install tools
    ```bash
    npm install
    ```

    Then run it with:
    ```bash
    npm run build
    ```

    It will give you some stats:
    ```
    1008 crushed.js
    1704 minified.js
    5739 source.js
    ```

    ---

    DWTFYW license
    2014 - @greweb
    51 changes: 51 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    <!doctype html>
    <html>
    <head>
    <title>JS1k, [COMPO] demo submission [ID]</title>
    <meta charset="utf-8" />
    <style>
    html, body { margin: 0; padding: 0; border: 0; }
    #c { display: block; } /* kill scrollbars from hell */
    </style>
    </head>
    <body>
    <canvas id="c"></canvas>
    <script>
    var a = document.getElementsByTagName('canvas')[0];
    var b = document.body;
    var d = function(e){ return function(){ e.parentNode.removeChild(e); }; }(a);
    // unprefix some popular vendor prefixed things (but stick to their original name)
    var AudioContext =
    window.AudioContext ||
    window.webkitAudioContext;
    var requestAnimationFrame =
    window.requestAnimationFrame ||
    window.mozRequestAnimationFrame ||
    window.webkitRequestAnimationFrame ||
    window.msRequestAnimationFrame ||
    function(f){ setTimeout(f, 1000/30); };

    // fix bug in safari: http://qfox.nl/weblog/218
    document.body.clientWidth;
    // auto resize (original) canvas. call `onresize(w,h) to limit the size of the canvas
    (window.onorientationchange = window.onresize = function(a){
    var mw = false;
    var mh = false;
    var max = Math.max;

    return function(w,h){
    if (arguments.length === 2) {
    mw = w;
    mh = h;
    }
    a.style.width = (a.width = max(mw, innerWidth)) + 'px';
    a.style.height = (a.height = max(mh, innerHeight)) + 'px';
    };
    }(a))();

    var c = a.getContext('2d');
    </script>
    <script type="text/javascript" src="source.js"></script>
    </body>
    </html>

    11 changes: 11 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    {
    "name": "js1k_template",
    "version": "0.0.0",
    "devDependencies": {
    "uglify-js": "2.4.x",
    "jscrush": "0.0.0"
    },
    "scripts": {
    "build": "cat source.js | uglifyjs -c unused=false | tee minified.js | jscrush > crushed.js && wc -c *.js"
    }
    }
    12 changes: 12 additions & 0 deletions source.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@

    // Template of source code
    // Following code is just a suggestion

    t = 0;

    L = function () {
    setTimeout(L, 9);
    c.fillRect(0, 10, t++, 50);
    }

    L();