esedic
3/24/2017 - 12:29 PM

Example of loading scripts with RequireJS in Joomla

Example of loading scripts with RequireJS in Joomla

<script src="<?php echo $this->baseurl. '/templates/' . $this->template . '/js/require.js'; ?>"></script>
<script>
	requirejs.config({
		baseUrl: '<?php echo $this->baseurl; ?>',
		paths: {
			jquery : 'media/jui/js',
			themejs : '<?php echo $this->baseurl. '/templates/' . $this->template . '/js'; ?>'
		}
	});

	requirejs(['jquery/jquery.min', 'jquery/jquery-noconflict', 'jquery/jquery-migrate.min', 'jquery/bootstrap.min', 'themejs/template'], function(){
		console.log('scripts loaded!');
	});
</script>