Last active
January 4, 2016 06:38
-
-
Save mayeenulislam/d0ac320973e9189fe559 to your computer and use it in GitHub Desktop.
Check the latest jQuery library from the server. If fails, load the library from the local directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* According to the lhrec_106's answer at StackOverflow | |
* http://stackoverflow.com/a/17339542/1743124 | |
*/ | |
$jQueryLatestURI = "http://code.jquery.com/jquery-latest.min.js"; | |
@$connection = fopen( $jQueryLatestURI, "r" ); | |
/** | |
* FALLBACK | |
* Check whether the jQuery library from server is available or not | |
* If available, load from server, | |
* If not, load from the local 'js' directory | |
*/ | |
if($connection) { | |
/* Latest jQuery Library from Server */ | |
<script type='text/javascript' src='<?php echo $jQueryLatestURI; ?>'></script> | |
} else { | |
/* In-Package jQuery Library */ | |
<script type='text/javascript' src='js/jquery.js'></script> | |
} //endif($connection) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment