Page speed improvements

Hi, how can I solve these 2 problems?

I think these are minor issues. The js resources are identical but are not really being served from two different URL’s. ?XXXX at the end of the URL are just strings to ensure that the latest version of the script is loaded rather than a cached version. I suspect that the script is being called twice on the same page Probably through two separate code widgets that use the same js. file. If you only call the script once this error will usually disappear. You should always check your code calls to make sure they are only called once per page. You can reference the JS many times, but it should only be called once. This is often done on third-party hosting servers that serve resources. Every time the page loads and the resource is requested, the number string changes to ensure that the page doesn’t used a cached version (which may be older)

The expiration of the other files means that the browser doesn’t know if it should call a newer version or wait until a specific time/date before loading the resource again. As a consequence, it probably calls the files on every page load.

The way you can overcome most of these types of issues is to self host the resources rather than call them from third-party servers. You then load the resources once on each page either through the head of the page or before the closing body tags. Once that is done, you can reference those resources as often as you like in the web page. The only time a new version will be loaded is when you republish your site in the future.

@hendon52 I was thinking that maybe the OP should use leverage browser cache through the htaccess. I do this as standard on websites, though never thought of adding fonts, which are self-hosted.

It’s certainly an option, but shouldn’t really be necessary if the OP organises things well in the site itself. To be quite honest, I don’t think the font issue is such a big deal. Although, I always prefer to host my own fonts (and scripts for that matter) just in case the serving server is off-line for some reason. Anyway, a couple of options to go at - always nice to have choices.

I generally do something along these lines, which is pretty standard. In theory that could include fonts as well. I agree it’s not a big deal though and also that it’s better to self-host fonts for various reasons.

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType video/mp4 "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

Hi, I tried to edit the .htaccess file on my hosting


but GT Metrix said always that the video have no expiration