Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

How to use jQuery File Upload with RequireJS

Sebastian Tschan edited this page Sep 14, 2014 · 3 revisions

First, download and add require.js to the js directory.

Next, edit index.html and replace all the script sources starting with jQuery:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
...
<script src="js/main.js"></script>

Replace them with the following single script source:

<script data-main="js/main" src="js/require.js"></script>

Next, edit js/main.js and replace its content with the following:

require(
    [
        'http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js',
        'https://blueimp.github.io/JavaScript-Templates/js/tmpl.min.js',
        'https://blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js',
        'https://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js',
        'js/jquery.iframe-transport',
        'js/jquery.fileupload-ui'
    ],
    function() {
        $('#fileupload').fileupload({
            url: 'server/php/'
        });
    }
);