Skip to content

Instantly share code, notes, and snippets.

@vaclavbohac
Created March 5, 2011 12:55
Show Gist options
  • Select an option

  • Save vaclavbohac/856334 to your computer and use it in GitHub Desktop.

Select an option

Save vaclavbohac/856334 to your computer and use it in GitHub Desktop.
Example of asynchronous loading of JS app.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8"/>
<title>Testing of asynchronous loading</title>
<script src="js/yepnope.1.0.0-min.js"></script>
<script>
(function (global, doc) {
global.MyApp = {
init: function () {
var that = this;
$(function () {
that.createLinks();
});
},
createLinks: function () {
$("#wrapper").find("span").each(function () {
var elem = $(this);
elem.parent().append($("<a>", {
text: elem.html(),
href: "#"
}));
elem.remove();
});
}
};
}(this, this.document));
yepnope({
load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js',
callback: function () {
MyApp.init();
}
});
</script>
</head>
<body>
<div id="wrapper">
<span>Home</span>
<span>About</span>
<span>Contact</span>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment