<?php
	// See at https://code.jquery.com/
	// const JQUERY_SRC = 'https://code.jquery.com/jquery-3.4.1.slim.min.js'; // 227ms
	const JQUERY_SRC = 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.slim.min.js'; // 69ms
	const JQUERY_INTEGRITY = 'sha256-pasqAKBDmFT4eHoN2ndd6lN370kFiGUFyTiUHWhU7k8=';
?>
<!DOCTYPE html>
<html lang="fr">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<title>Télécharger jQuery</title>
</head><body>
	<p id="notif">
		Téléchargement de jQuery en cours
	</p>
	<script type="text/javascript">
		(function() {
			'use strict';
			if(typeof jQuery !== 'function') {
				const myScript = document.createElement('SCRIPT');
				myScript.src = '<?php echo JQUERY_SRC; ?>';
				myScript.integrity = '<?php echo JQUERY_INTEGRITY; ?>';
				myScript.crossOrigin = 'anonymous';
				myScript.onload = function(event) {
					const msg = this.src + ' loaded';
					console.log(msg);
					const el = document.getElementById('notif');
					if(el != null) {
						el.textContent = msg;
					}
				};
				document.head.appendChild(myScript);
			}
		})();
	</script>
</body></html>