jsfiddle jquery workaround

Currently https://code.jquery.com is not reachable for some people (ipv6 issues) . This fiddle is a workaround to copy paste above other fiddles using jquery to make them work again.

by Laurens Maneschijn

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- https://jsfiddle.net/ElMoonLite/e9um30x7/ -->

<!-- 
remove above to see if the built in jsfiddle jquery loading works again
-->

<a target="_blank" href="https://code.jquery.com">https://code.jquery.com</a> is not available for some people (apparently ipv6 issues in pathing).<br>
This causes the automatic loading of jQuery in jsfiddle to fail.<br>
This fiddle tries to find a simple way to work around it.<br>
Currently it seems enough to just copy paste a script tag on top of the html panel loading it manually.<br>

<hr>

Testing if jQuery workaround works... output should follow with jQuery version:<br>

JavaScript

// turns out all you need is copy paste the script tag to the html panel:
// <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js">< /script>
// ( < /script> broken script tag on purpose, jsfiddle does not like it in this javascript panel)

/*
var $;
(function(){
	// https://code.jquery.com is not reachable so all jquery is failing.
	// For now as (hopefully) temp workaround, using other cdn:
	//
	// Put this in html tab: [script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"][/script]
	// (when putting [/script] here with proper tag characters everything breaks so pasted with square brackets)
	//
	// The while loop is evil, but this makes code halt before code below until we have $ available.
	// After 3 sec or n loops break out so we do not get stuck in an infinite loop.
	//
	var script_loaded = false,  fallback = false, n=0;
	var script = document.createElement('script');
	script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js';
	script.type = 'text/javascript';
	script.onload = function(){script_loaded = true};
	document.head.appendChild(script);
//	console.log(script);

	setTimeout(function(){ fallback = true; }, 3000);
	while(!window.$) {
		if(script_loaded || fallback || n++ > 10000){break;}
	}
	$ = window.$;
})();
*/

$(document).ready(function(){
	if ($ && $.fn && $.fn.jquery) {
		var msg = 'jQuery loaded v:' + $.fn.jquery;
		document.body.innerHTML += msg;
		setTimeout(function(){alert(msg);}, 1);
	}
});