Posts tagged html
PHP array to html attributes
Apr 13th
/**
* Generates HTML Node Attribures
* @param string $glue
* @param array $pieces
* @return string
*/
public static function array_to_html_attributes($glue, $pieces) {
$str = "";
if (is_array($pieces)) {
$str = " ";
foreach($pieces as $key => $value) {
if (strlen($value) > 0) {
$str .= $key . $glue . '"' . $value . '" ';
}
}
}
return rtrim($str);
}
HTML remove cookies from static files, images etc
Mar 24th
If you have not configured your application and server, it might send them to browser with cookie information.
that’s costing you as extra traffic and slow load times.
<FilesMatch "\.(css|js|jpg|jpeg|png|gif)$">
<IfModule mod_headers.c>
Header set cookie ""
</IfModule>
</FilesMatch>
HTML Reduce time on page load using performance images
Mar 24th
used this method while ago when i was working for one of those websites in top 10 the purpose was to reduce the loading time of the page and improve the parallel download
$(document).ready(function() {
/* apply performance image */
$.each($('img'), function(k, v) {
var src = $(v).attr('src');
if (src.indexOf('#') >= 0) {
src = src.split('#');
$(v).attr('src', src[1]);
}
});
});
the trick is simple. host a 1×1.gif image or don’t. up to you and separate the actual image path with ‘#’ and when the dom is ready start replacing them with original path.
make sure your images cachable.


LinkedIn
Twitter
Skype