Audisto JavaScript Error Checker

How to detect issues with JavaScript on your website

JavaScript helps to add dynamic elements to a website. It is a heavily used technology in websites today. Issues with JavaScript can lead to a number of follow up problems, like unnecessary high file sizes, long loading time as well as poor usability and undefined behaviour in certain situations.

You can identify the most common mistakes with JavaScript using this hints section.

Example: Audisto JavaScript Error Check with the JavaScript hint reports for the current crawl

Audisto JavaScript Error Check with the JavaScript hint reports for the current crawl

Here is the list of all specific hints related to JavaScript, that can be identified with the help of the Audisto Crawler.

Table Of Content

Hints

<a> has both href and onclick attributes

Description

If a link with an href attribute and an onclick attribute is found, the URL is flagged with this hint.

Example

Link calling a JavaScript function with the onclick event:

<a href="http://example.com/page.html" onclick="alert('hello world');">Link</a>

Link calling a JavaScript redirect with the onclick event:

<a href="http://example.com/page.html" onclick="document.href='http://example.com/page1.html';">Link</a>
Importance

The onclick attribute defines a JavaScript action to happen when the "onclick" event for the link is triggered, i.e. the user clicks the link.

This may lead to unexpected behaviour and user experience issues for users with and without JavaScript activated.

Be aware that modern search engines like Google follow JavaScript links like these. If the JavaScript redirect leads to a different target than the HTML link, the search engine might start to mistrust the links.

Operating Instruction

We suggest that you check instances of onclick attributes in HTML links and decide if the onclick usage is required. Remove any onclick attributes that are not needed.

<script> loaded multiple files from local domain

Description

If multiple JavaScript files from the crawled domain are loaded, the URL is flagged with this hint. Use this report to discover all URLs that include more than one JavaScript file from the local domain.

Example
<script type="text/javascript" src="file1.js"></script>
<script type="text/javascript" src="file2.js"></script>
<script type="text/javascript" src="file3.js"></script>
Importance

Depending on the protocol that is used, it may or may not be better to aggregate multiple included JavaScript files from the local domain into just one file to minimize the number of HTTP requests required to display the webpage in the browser.

In HTTP 1.0 and HTTP 1.1, clients limit the maximum number of parallel requests per host. This leads to delays if more connections are required for loading the webpage. Therefore, in HTTP 1.x it is better to aggregate multiple included JavaScript files from the local domain.

In HTTP 2, multiple files are transferred using a single connection. The limitation regarding the number of requests from HTTP 1.0 and HTTP 1.1 does not apply.

Operating Instruction

HTTP 1.x: The JavaScript files should be combined into a single file and the number of files should be minimized, if possible.

HTTP 2: No changes required.

<script> more than 3 KB within HTML

Description

If more than 3 KB of JavaScript is found within the HTML, the URL is flagged with this hint. Use this report to identify all occurrences of inline JavaScript with more than 3 KB in total.

Importance

If more than 3 KB of inline JavaScript is found in one HTML document, this usually indicates unnecessarily bloated code. 3 KB may not seem like a lot, but the numbers can add up if this occurs on larger websites. This leads to:

  • waste of bandwidth
  • lower performance
  • poor overall user experience

Moving inline JavaScript to separate files is a best practice for performance optimization.

Operating Instruction

JavaScript should be placed in a separate file whenever this helps to improve performance.