How to preload images, js and css files?

I create a website from scratch, and I really was in this in the late 90s, but since then the network has changed a lot! And I'm more of a designer, so when I started hosting this site, I basically made the php system to make the site more “dynamic”

When you first visit the site, you will be presented on the login screen if you have not logged in (cookies). If you are not logged in, a page called access.php is entered. I thought that at this moment I would preload the heaviest images. Thus, when the user logs in, the images are already cached. And it works the way I want. But I still notice that the largest image is still not displayed right away. So it seems pointless.

All this made me rethink how the site is structured and how scripts and css files are loaded. Using FireBug and YSlow with Firefox, I see several pointers, such as expiring headers and reducing the size of each script. But is this really a criminal?

For example, would it really be really stupid in the main index.php? The whole site is basically structured this way

<?php
require("dbconnect.php");
?>

<?php
include ("head.php");
?>

And below it is basically just the body and content of the site. Head.php, however, consists of doctype, head parts, linking two CSS stylesheets, a jQuery library, a jQuery validation mechanism, a Cufon and Cufon font file, and then a small piece of Cufon.Replace.

index.php, "footer.php", jsLoader - js. , -, , - , " " " , " .. ) ?

, , , . , . YSlow , :

doc(1) - 5.8K
js(5) - 198.7K
css(2) - 5.6K
cssimage(8) - 634.7K
image(6) - 110.8K

, , cssimage (8) , , .

+3
4

, , 1 . css, . , : http://css-tricks.com/css-sprites/

, , , -: Just Keep It Simple. , JS , , , ? , ...

+2

:

jQuery , ajax .js .css , . , , , - -.

.

+2

, CSS HTML, , jQuery ImageLoader. -, , .

, , - JS , jquery.js. jquery.js HTML, . SCRIPT HTML.

+1

, , , , , , .

-, , . 100 - 200 .

, , . , jQuery.

CSS.

? . PNG IrfanView PNGOUT 25% , , , 8- , , . , Stack Overflow, : http://sstatic.net/so/Img/wmd-buttons.png

+1
source

Source: https://habr.com/ru/post/1740152/


All Articles