Commit 94fa4f7
Optimize main.js (#20093)
This Pull Request optimizes the functions used in
`/docs/_spec/public/scripts/main.js`.
## Changes made:
1. `currentChapter()` function was simplified using `split()` and
`pop()` instead of `lastIndexOf()` and `substring()`.
2. Used template literals for string interpolation.
3. Simplified the `heading` function by reducing repetitive code and
improving readability.
4. Changed `.removeClass()` and `.addClass()` to `.toggleClass()` for
toggling the class based on condition.
5. General cleanup and optimization for better readability and
performance.
[Cherry-picked 6d29951]1 parent aa18455 commit 94fa4f7
1 file changed
+13
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 2 | + | |
6 | 3 | | |
7 | 4 | | |
8 | 5 | | |
9 | | - | |
10 | | - | |
| 6 | + | |
| 7 | + | |
11 | 8 | | |
12 | | - | |
13 | | - | |
| 9 | + | |
14 | 10 | | |
15 | | - | |
| 11 | + | |
16 | 12 | | |
17 | | - | |
| 13 | + | |
18 | 14 | | |
19 | | - | |
20 | | - | |
| 15 | + | |
21 | 16 | | |
22 | | - | |
23 | | - | |
| 17 | + | |
| 18 | + | |
24 | 19 | | |
25 | 20 | | |
26 | | - | |
27 | 21 | | |
| 22 | + | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
31 | | - | |
| 26 | + | |
32 | 27 | | |
33 | 28 | | |
34 | 29 | | |
| |||
64 | 59 | | |
65 | 60 | | |
66 | 61 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 62 | + | |
| 63 | + | |
71 | 64 | | |
0 commit comments