動的ローダーを組み込む
突然考えだす。
F/WのviewにJavaScriptファイルを動的に読み込ませて初期ロード減らす。
<?php // 実際はJSONでもArrayでもYAMLでもXMLでもなんでもいい $html = ""; $js = ""; $example = array( 'fristload' = array( 'http://example.net/jquery.js', 'http://example.net/common.js', ), 'secondload' = array( 'http://example.net/event.js', ), ); foreach($example['fristload'] as file) { $html .= "<script type=\"text/javascript\ src=\"{$file}\"></script>"; } foreach($example['secondload'] as $key => file) { $js = <<< JS var s{$key} = document.createElement('script'); s{$key}.src = "{$file}"; document.body.appendChild(s{$key}); JS; } ?>
<html><head> <?php echo $html; ?> <script type="text/javascript"> <?php echo $js; ?> </script> </head> <body> テストだよ! </body> </html>
汚いソースだなぁ、って言わないように。
むしろ書いてみたら超普通だった罠。オリジナリティゼロ。
しかもよく見たらロード開始イベント設定してないし・・・。やっぱ会社でやろ・・・。