Skip to content

Instantly share code, notes, and snippets.

@cviebrock
Created September 18, 2013 03:30
Show Gist options
  • Select an option

  • Save cviebrock/6604194 to your computer and use it in GitHub Desktop.

Select an option

Save cviebrock/6604194 to your computer and use it in GitHub Desktop.

index.html:

<html lang="en">
	<head>
	</head>
	<body>
		...
		<script data-main="/js/config" src="/js/lib/require.min.js"></script>
		<script src="/js/signin.js"></script>
	</body>
</html>

/js/config.js:

requirejs.config({
		paths: {
			'jquery': [
				'//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min',
				'lib/jquery.min'
			],
			'bootstrap': 'lib/bootstrap.min'
		},
		shim: {
			'bootstrap': {
				deps: ['jquery']
			}
		}
});

/js/lib/jquery.min.js - exists

/js/lib/bootstrap.min.js - exists

/js/signin.js:

require(['jquery','bootstrap'], function ($) {

	// the JS I want to run on ready

	var $bg = $('#bg'),
		src = $bg.find('img').attr('src'),
		$img = $('<img>').attr('src',src).on('load', function() {
			$bg.fadeIn(1000);
		});

});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment