When a website is referencing a JS and CSS file and it isn’t there, due to the link being broken, it can cause a knock-on effect in several ways. It can certainly impact your SEO performance alongside user experience – causing an unnecessary delay. This particular error can often be generated in many different ways, tools which minify may break URLs due to how they name the files, the codebase could have an incorrect URL path used or perhaps the original asset has been deleted and is no longer available.
The nuance of this error is a browser will spend a bit of time before it concludes that a file path is broken. This delay can often lead to longer loading speed times and when you operate within SEO, milliseconds count when it comes to website loading speed and experience.
The most sinister part of this particular error is it can often make a website not look correct or function properly, especially if the JS and CSS file is a critical asset – JS files which are not located correctly can break contact forms for example or CSS files can dramatically change the look and feel of a website. Due to the diversification of CSS and JS files (often multiple files), it can occur that a file is broken but doesn’t give any sign at a front end level, you have to delve deeper into the source code for proper diagnostics.
How do I identify JS and CSS files that are broken?
SEO software is your friend here, they will scan the full site looking at all the pages, if you ensure the toggles are on for monitoring assets it’ll give you useful feedback. It’s likely that the software will flag these errors as a broken JS and CSS file but occasionally it may come through as a specific error such as 5XX server error or not found 4XX header error.
How do I resolve broken JS and CSS files on my website?
There are two main fixes here but you need to establish if the missing asset is useful to the site function or aesthetics, or no longer needed. If the file is no longer required due to a design refresh for example, you just need to remove the HTML/link that requests the file. If the file is essential and missing, you can potentially look at your backups and paste the file back into the desired location – of rollback any software which is changing the source or file name. If you’ve had a good handle on SEO with your website then you may be able to pinpoint this issue to a specific date in time – if anything has been changed on the website around that time? Perhaps a server move that forgot to move all the files over? Or perhaps a new minification tool or even stopping a caching plugin which may inject the over onto the asset.
How do I prevent breaking CSS and JS files on my website?
The main culprits for causing broken CSS and JS files is renaming files on the server, changing servers and not moving all files or deploying a function which minifies assets, renames them but doesn’t have the ability to update the HTML to reference the new file. Running SEO crawling software after a big development change which can influence these files may be beneficial, if you capture it early on you can normally rollback easily, but if you leave it too long and you have new orders / new customers, it can be difficult to rollback without losing data.
Additional notes on broken CSS and JS files
- Don’t forget to take regular backups of your site – ideally nightly. I also recommend taking a 30-day snapshot, sometimes the site can override backups and if you don’t pick up the missing file in time, you may lose it too.
- Carrying out an SEO crawl on the website after any major development change can often give you a quick and easy window of rollback in the event something has changed in a negative way.
- Use competent developers – sounds straight forward but don’t have a go changing code yourself unless you are a developer. This can cause major issues with the source code and cause a knock-on effect on SEO and user experience too.