目标:所有图像在首次加载时出现.
当前:如果幸运的话,第一次加载时会出现两三张图像; 需要页面引用才能查看所有图像.
这是我的第一个手工编写的网站.客户是设计师,所以高质量的图像很重要.性能和速度对我来说很重要,因为现在我的投资组合中,我不能接受部分功能的网站作为我的工作.
这是一个示例页面:
http://elisamantovani.com/pages/book_design.html
查看其他页面.同样的问题.
更新:
许多人建议缩小图像文件大小.不管怎样,只有少数图像很大,但现在它们都很好.没有图像大于200kb,大多数图像检查<100kb.问题依然存在.
谷歌建议阻止页面呈现的其他原因,例如渲染阻止JS/CSS.CSS应该阻止渲染直到加载,但不应该花费很长时间来加载.如果jQuery可以等到HTML/CSS渲染之后我想要它.
刚进入缓存控制.已将此添加到.htaccess提高性能一点点,但这只是将有助于后第一次加载,但需要的是对第一负载.
# One year for image files
<filesMatch ".(jpg|jpeg|png|gif|ico)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
# One month for css and js
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>
Run Code Online (Sandbox Code Playgroud) 我的程序需要获取用户的输入并将其保存到外部文件以供将来参考.这是代码的基本概要.
void newActivity(FILE *foutput) {
char name[31];
char description[141];
finput = fopen("activities.txt", "a");
printf("\n What is the name of your activity (up to 30 characters):\n");
fgets(name, sizeof(name), stdin);
printf("\nEnter a brief description (up to 140 characters) of what %s is about:\n",
fputs(name, stdout));
fgets(description, sizeof(description), stdin);
if (finput == NULL) {
printf("\nCould not open file.");
exit(1);
}
fprintf(foutfile, "%s\n", name);
fprintf(foutfile, "%s\n", description);
fclose(foutfile)
}
Run Code Online (Sandbox Code Playgroud)
当我运行一个只询问名称并打印该名称的简单测试程序时,一切都很好.它看起来像这样:
int main() {
char name[50];
fprint("What is your name? ");
fgets(name, sizeof(name), stdin);
fputs(name, …Run Code Online (Sandbox Code Playgroud) 我有一个数组数组,当运行脚本时,该数组的元素数可能会有所不同。
$strict = [
[0] => ['one', 'two', 'three', 'four'],
[1] => ['one', 'two', 'four', 'eight'],
[2] => ['two', 'four', 'ten', 'twenty'],
/* [x] => [. . .] */
];
$result = array_intersect($strict[0], $strict[1], $strict[2]);
print_r($result); //shows ['two', 'four'];
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情:
$result = array_intersect($strict);
Run Code Online (Sandbox Code Playgroud)
我在其中传递了一个动态长度的数组,并且array_intersect将遍历每个数组并仅接受公共条目。
这样做array_intersect($strict)不起作用,因为该函数至少需要两个参数。
也许像
array_intersect(function ($array) {
$list = '';
foreach ($array as $el) {
$list .= $el.',';
}
$list = rtrim($list, ',');
return eval($list);
});
Run Code Online (Sandbox Code Playgroud)
尽管此特定方法仍然会引发错误
警告:array_intersect():至少需要2个参数,给定1个
运行时php artisan migrate --seed,出现此错误:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'CreateCharactersTable' not found.
Run Code Online (Sandbox Code Playgroud)
这是该类:
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class CharacterSeeder extends Seeder
{
public function run()
{
DB::table('characters')->delete();
DB::table('characters')->insert([
'user_id' => 999,
'name' => 'Susan Strong',
'race' => 'orc',
'class' => 'assassin',
'image_location' => null,
'combat_level' => '0',
'base_str' => 6,
'base_int' => 4,
'base_apt' => 5,
'mod_str' => 9,
'mod_int' => 5,
'mod_apt' => 7,
'xp_str' => 1,
'xp_int' => 2,
'xp_apt' => 1,
'is_bot' => 1,
'created_at'=> '2017-04-02 17:53:02', …Run Code Online (Sandbox Code Playgroud)