What is a script?
On a website, a script is a piece of code that has been inserted into the HTML of the page. Its purpose is to perform or add functions within a web page.
defer seems like the best option in general. It would also be the best choice if the script has dependencies with other scripts and the order in which each is executed is important.
async would be ideal for scripts that manipulate or interact with the DOM before DOMContentLoaded and/or have no dependencies on other scripts.
This means that the entire main thread is stopped while the script is parsed, compiled and executed.
Solution: It is important to keep an eye here on how many resources are being executed and where request timeouts are happening, as these can be some of the main culprits which create bottlenecks in load time.
You can use GTMetrix Waterfall chart to identify the main problems on the load progression of a given website.
Scripts located in the head
Most of the scripts on a web page are located below the header. However, there are some scripts that need to be active every time a page is rendered and so they are placed in the header.
Two clear examples of these are the Google Analytics script for its tracking function and, precisely, the DWX script. Both are short and are optimized to minimize load time.
If a script has been blocked (e.g. through robots.txt) the ability to view and render a web page by the search engine may be impaired.
Google's John Mueller has already made it clear that:
- "Blocking scripts for Googlebot can impact its ability to render pages."
“Any features that requires user consent are auto-declined by Googlebot.” - Google Search
How the scripts used by DWX Inlinks work
DWX Inlinks is an IA driven internal link evaluator that helps your site to improve and boost your organic traffic.
All the scripts it generates are "no page layout imposed" and do not affect page loading performance by taking into account the main elements seen in the previous point.
Using our REST API, your site will be able to retrieve the data and embed it on your site's structure, without affecting the normal user experience.
Conclusions to consider
- Use tools such as Google PageSpeed Insights or GTMetrix to understand how your website loads and to make improvements.
- Avoid placing unnecessary scripts in the header of your web page.
- Don't block scripts via robots.txt (or in other ways) so that Google can crawl them correctly.
- Any features that require user consent are auto-declined by Googlebot.