Skip to content

Instantly share code, notes, and snippets.

@basememara
Created February 27, 2013 15:15
Show Gist options
  • Save basememara/5048648 to your computer and use it in GitHub Desktop.
Save basememara/5048648 to your computer and use it in GitHub Desktop.

Revisions

  1. basememara created this gist Feb 27, 2013.
    38 changes: 38 additions & 0 deletions main.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    ;(function () {
    var paths = { ... };

    //HANDLE JQUERY IF LOADED ALREADY TO AVOID OVERWRITING EXISTING JQUERY PROPERTIES AND PLUGINS
    //CHECK FOR OLD VERSIONS OF JQUERY
    var oldjQuery = !!(window.jQuery && !!window.jQuery.fn.jquery.match(/^1\.[0-4]/));

    //LOAD JQUERY IF NOT AVAILABLE OR BELOW MIN
    if (!window.jQuery || oldjQuery) {
    paths.jquery = [
    '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min',
    //If the CDN location fails, load from this location
    'libs/jquery/jquery.min'
    ];
    } else {
    //REGISTER THE CURRENT JQUERY
    define('jquery', [], function () { return window.jQuery; });
    }

    //CONFIGURE REQUIRE JS
    require.config({
    ...
    paths: paths,
    ...
    });

    //START REQUIRE JS
    require([
    'jquery',
    'app'
    ], function ($, App) {
    //HANDLE MULTIPLE JQUERY VERSIONS IF NECESSARY
    if (oldjQuery) $.noConflict(true);

    //INITIALIZE APP
    App.init();
    });
    })();