This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 768d5e9
committed
Load rustdoc's JS search index on-demand.
Instead of being loaded on every page, the JS search index is now
loaded when either (a) there is a `?search=` param, or (b) the search
input is focused.
This saves both CPU and bandwidth. As of Feb 2021,
https://doc.rust-lang.org/search-index1.50.0.js is 273,838 bytes
gzipped or 2,544,939 bytes uncompressed. Evaluating it takes 445 ms
of CPU time in Chrome 88 on a i7-10710U CPU (out of a total ~2,100
ms page reload).
Generate separate JS file with crate names.
This is much smaller than the full search index, and is used in the "hot
path" to draw the page. In particular it's used to crate the dropdown
for the search bar, and to append a list of crates to the sidebar (on
some pages).
Skip early search that can bypass 500ms timeout.
This was occurring when someone had typed some text during the load of
search-index.js. Their query was usually not ready to execute, and the
search itself is fairly expensive, delaying the overall load, which
delayed the input / keyup events, which delayed eventually executing the
query.1 parent 94736c4 commit 768d5e9
3 files changed
+69
-51
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | | - | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
1042 | | - | |
| 1042 | + | |
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
| 1046 | + | |
| 1047 | + | |
1046 | 1048 | | |
1047 | 1049 | | |
1048 | 1050 | | |
1049 | 1051 | | |
1050 | 1052 | | |
1051 | 1053 | | |
1052 | 1054 | | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
| 1055 | + | |
1056 | 1056 | | |
1057 | 1057 | | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1058 | 1064 | | |
1059 | 1065 | | |
1060 | 1066 | | |
| |||
1076 | 1082 | | |
1077 | 1083 | | |
1078 | 1084 | | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | 1085 | | |
1083 | 1086 | | |
1084 | 1087 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
1922 | 1923 | | |
1923 | 1924 | | |
1924 | 1925 | | |
1925 | | - | |
1926 | | - | |
| 1926 | + | |
| 1927 | + | |
1927 | 1928 | | |
1928 | 1929 | | |
1929 | 1930 | | |
| |||
1935 | 1936 | | |
1936 | 1937 | | |
1937 | 1938 | | |
1938 | | - | |
1939 | | - | |
| 1939 | + | |
| 1940 | + | |
1940 | 1941 | | |
1941 | 1942 | | |
1942 | 1943 | | |
| |||
1999 | 2000 | | |
2000 | 2001 | | |
2001 | 2002 | | |
2002 | | - | |
2003 | 2003 | | |
2004 | 2004 | | |
2005 | 2005 | | |
| |||
2017 | 2017 | | |
2018 | 2018 | | |
2019 | 2019 | | |
2020 | | - | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
2021 | 2026 | | |
| 2027 | + | |
2022 | 2028 | | |
2023 | 2029 | | |
2024 | 2030 | | |
| |||
2029 | 2035 | | |
2030 | 2036 | | |
2031 | 2037 | | |
2032 | | - | |
2033 | | - | |
2034 | | - | |
2035 | | - | |
2036 | | - | |
2037 | | - | |
2038 | | - | |
2039 | | - | |
2040 | 2038 | | |
2041 | 2039 | | |
2042 | 2040 | | |
2043 | 2041 | | |
2044 | 2042 | | |
2045 | 2043 | | |
2046 | 2044 | | |
2047 | | - | |
2048 | | - | |
2049 | | - | |
2050 | 2045 | | |
2051 | 2046 | | |
2052 | 2047 | | |
| |||
2057 | 2052 | | |
2058 | 2053 | | |
2059 | 2054 | | |
2060 | | - | |
| 2055 | + | |
2061 | 2056 | | |
2062 | 2057 | | |
2063 | 2058 | | |
| |||
2862 | 2857 | | |
2863 | 2858 | | |
2864 | 2859 | | |
2865 | | - | |
| 2860 | + | |
2866 | 2861 | | |
2867 | 2862 | | |
2868 | 2863 | | |
2869 | 2864 | | |
2870 | 2865 | | |
2871 | 2866 | | |
2872 | | - | |
2873 | | - | |
2874 | | - | |
2875 | | - | |
2876 | | - | |
2877 | | - | |
2878 | | - | |
2879 | | - | |
2880 | | - | |
2881 | | - | |
2882 | | - | |
2883 | | - | |
2884 | | - | |
2885 | | - | |
2886 | | - | |
2887 | | - | |
2888 | | - | |
2889 | | - | |
2890 | | - | |
2891 | 2867 | | |
2892 | | - | |
| 2868 | + | |
2893 | 2869 | | |
2894 | | - | |
2895 | | - | |
| 2870 | + | |
| 2871 | + | |
2896 | 2872 | | |
2897 | 2873 | | |
2898 | 2874 | | |
2899 | 2875 | | |
2900 | 2876 | | |
2901 | 2877 | | |
2902 | 2878 | | |
2903 | | - | |
| 2879 | + | |
2904 | 2880 | | |
2905 | 2881 | | |
2906 | 2882 | | |
| |||
2969 | 2945 | | |
2970 | 2946 | | |
2971 | 2947 | | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
2972 | 2985 | | |
2973 | 2986 | | |
| 2987 | + | |
2974 | 2988 | | |
0 commit comments