Skip to content

Instantly share code, notes, and snippets.

Created January 29, 2018 09:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
(function(url) {
console.log('is jQuery.timeago defined?');
console.log((typeof(jQuery.timeago) !== 'undefined'));
var tag = 'script';
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if(request.readyState === 4) {
console.log('we have fetched the script');
if(request.status === 200) {
var javascript = request.responseText;
console.log('the javascript looks something like this: ' + javascript.substr(0,50));
console.log('evaluated the javascript');
var scriptTag = document.createElement(tag);
scriptTag.innerHTML = javascript;
console.log('is jQuery defined?');
console.log((typeof(jQuery) !== 'undefined'));
console.log('is jQuery.timeago defined?');
console.log((typeof(jQuery.timeago) !== 'undefined'));
console.log('is $.timeago defined?');
console.log((typeof($.timeago) !== 'undefined'));
} else {
console.log('error while loading the script :(');
}"GET", url);
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment