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 attribute

Description

If a link with a 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 redirects lead to a different target than the HTML link, the search engine might start to mistrust the links.

Operating Instruction

We suggest checking instances of onclick attributes on HTML links and decide if the onclick usage is required. Remove any onclick attribute that is 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. Discover all URLs that include more than one JavaScript file from the local domain by using this report.

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 might or might not be better to aggregate multiple included JavaScript files from the local domain to just one file to minize the number of HTTP requests required to display the HTML 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 URL. Therefore, in HTTP 1.x it is better to aggregate multiple included JavaScript files from the local domain.

In HTTP 2, multiple files are tranfered 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 files should be combined into a single file and minimized, if possible. HTTP 2: No changes required regarding this hint.

<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 are found in one HTML document, this usually indicates unnecessarily bloated code. 3 KB doesn't seem like a lot, but the numbers can add up if this occurs on larger websites. This leads to:

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

Moving inline JavaScript to separate files, is part of the best practice for performance optimization.

Operating Instruction

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