116 |
} |
} |
117 |
} |
} |
118 |
|
|
119 |
sub _inline_path_size { |
sub _inline { |
120 |
my ( $self, $path ) = @_; |
my ( $self, $path ) = @_; |
121 |
-s $path < $self->inline_smaller_than && -s $path; |
warn "# _inline $path"; |
122 |
|
-e $path && -s $path < $self->inline_smaller_than && -s $path; |
123 |
} |
} |
124 |
|
|
125 |
sub _head_html { |
sub _head_html { |
127 |
my $out = ''; |
my $out = ''; |
128 |
foreach my $path ( @head ) { |
foreach my $path ( @head ) { |
129 |
$path =~ s!^/!!; |
$path =~ s!^/!!; |
|
my $size = $self->_inline_path_size( $path ); |
|
130 |
if ( $path =~ m/\.js$/ ) { |
if ( $path =~ m/\.js$/ ) { |
131 |
$out .= $size ? |
my $size; |
132 |
|
$out .= $size = _inline( $path ) ? |
133 |
qq|<script type="text/javascript">\n/* inline $path $size bytes */\n\n| . read_file($path) . qq|\n</script>| : |
qq|<script type="text/javascript">\n/* inline $path $size bytes */\n\n| . read_file($path) . qq|\n</script>| : |
134 |
qq|<script type="text/javascript" src="/$path"></script>|; |
qq|<script type="text/javascript" src="/$path"></script>|; |
135 |
} elsif ( $path =~ m/\.css$/ ) { |
} elsif ( $path =~ m/\.css$/ ) { |
136 |
$out .= $size ? |
my $size; |
137 |
|
$out .= $size = _inline( $path ) ? |
138 |
qq|<style type="text/css">\n/* inline $path $size bytes */\n\n| . read_file( $path ) . qq|\n</style>| : |
qq|<style type="text/css">\n/* inline $path $size bytes */\n\n| . read_file( $path ) . qq|\n</style>| : |
139 |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
qq|<link type="text/css" rel="stylesheet" href="/$path" media="screen">|; |
140 |
} elsif ( $path =~ m{<.+>}s ) { |
} elsif ( $path =~ m{<.+>}s ) { |