JDK-8246155 : The javadoc generated website loads some data twice
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 14.0.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2020-05-28
  • Updated: 2020-08-05
  • Resolved: 2020-05-29
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
The javadoc generated website loads its search index twice. Wasting data transfer for both the server and the client. For example, each visit of https://docs.oracle.com/en/java/javase/14/docs/api/index.html wastes ~4.6MB of data, or ~600KB of compressed data. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. open a modern browser
2. open developer tools > network
3. enable "Disable Cache"
3. load https://docs.oracle.com/en/java/javase/14/docs/api/index.html


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For module-search-index, package-search-index, type-search-index, member-search-index and tag-search-index, either the zip file OR the Javascript file is loaded.
ACTUAL -
Both the 5 zip files (*-search-index.zip) AND the 5 Javascript files (*-search-index.js) are loaded. This wastes ~4.6MB of data, or ~600KB compressed.

CUSTOMER SUBMITTED WORKAROUND :
The following is not a workaround, but a direction for fixing the bug:
In https://docs.oracle.com/en/java/javase/14/docs/api/script.js , the author tried to load 5 zip files, and fall back to javascript files if the zip files fail. The problem is that the loading of the zip files are asynchronous (see $.get(),  JSZip.loadAsync(), zip.file().async() ). Therefore, the *searchIndex will not be loaded right away. In light of that, we should not check these variables and load fallback right away. Instead, do the checking and fallback-loading in each callback, for example in $.get().fail() and JSZip.loadAsync().then(handleZip(zip), handleError(error)) and etc.

FREQUENCY : always