Skip to content

Instantly share code, notes, and snippets.

@zhangwc
Created December 27, 2013 02:45
Show Gist options
  • Save zhangwc/8141870 to your computer and use it in GitHub Desktop.
Save zhangwc/8141870 to your computer and use it in GitHub Desktop.
php load javascript files
#########################################################################################
# - 这里列出所有js文件名
# - 使用#作为注释
# - pre.js、post.jsの順序の変更は不可。
#########################################################################################
pre.js
NttObject.js
# ....
post.js
<?php
header("Content-Type: application/javascript;charset=UTF-8");
header("Expires: 0");
$fileBaseDir = "./dev";
$str = file_get_contents($fileBaseDir . "/files.txt");
$files = explode("\n", $str);
$response = "";
foreach ($files as $file) {
$file = trim($file);
if ($file == "") continue;
if ($file{0} == "#") continue;
$content = file_get_contents($fileBaseDir . "/" . $file);
$content = $content !== false ? $content : "";
$response .= $content . "\n";
}
echo $response;
?>
})(window);
(function(window, undefined) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment