Context Require js
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
test
LICENCE
README.md
cr-inview.js
cr.js

README.md

Context Require

This is a tiny script that allows you to load (require) js files based on the content of a page.

Usage

<div class="cr" data-cr="fancy">
	<p>This part is made all fancy</p>
</div>
…
…
<script data-main="js/main" src="/js/require.js"></script>
//--fancy.js

define(['jquery'], function($){

	$.fn.make_fancy = function(){
		this.animate({fontSize:'+=50'})
	};

	return function(content){
		$(content).find('p').make_fancy();
	}

});

//--main.js

require(['cr']);

see example.html