Loading fresh JS code
11
Enforce loadig fresh script code for the external javascript files. Compatible with HTTP 1.0.
<?php
function load_js($localPath) {
if (file_exists($localPath)) {
echo '<'.'script language="JavaScript" src="'.htmlspecialchars($localPath.'?'.filemtime($localPath)).'"><'.'/script>';
} else {
user_error("Unknown file:'$localPath'");
exit;
}
}
load_js('test.js');
load_js('there-is-no-such-file.js');
?>
...
function load_js($localPath) {
if (file_exists($localPath)) {
echo '<'.'script language="JavaScript" src="'.htmlspecialchars($localPath.'?'.filemtime($localPath)).'"><'.'/script>';
} else {
user_error("Unknown file:'$localPath'");
exit;
}
}
load_js('test.js');
load_js('there-is-no-such-file.js');
?>
...






There are currently no comments for this snippet.