New Features
- Add Knocket chat support with new
knocket.pugtemplate and config option - Add script and CSS caching mechanism (
scriptCache/cssCache) to prevent duplicate loads - Add
rafThrottleutility function based onrequestAnimationFrame - Add HTML escape function (
sanitizeString) to prevent XSS injection
Performance
- Replace TOC scroll handling with
IntersectionObserverinstead of throttle + iteration, significantly reducing scroll event computation - Switch scroll handler from
btf.throttletobtf.rafThrottle, syncing with browser render frame rate - Add
rafThrottletoresizeevent handler - Change
scrollToDestsmooth scrolling from linear interpolation to easeOutQuart easing - Cache
goUpElement/scrollPercentElementin closure forrightsideScrollPercent, avoiding DOM queries on every scroll - Cache
page-header/menuselements in closure foroverflowPaddingR - Cache
document.getElementByIdresults insidebarFnfor hamburger menu toggle - Wrap
adjustMenu'sclassList.toggleinrequestAnimationFrame - Refactor
forPostFnto accept$articleparameter; all internal functions (addHighlightTool,addPhotoFigcaption,runLightbox,scrollFnToDo,addTableWrap,clickFnOfTagHide,tabsFn) use the passed$articleinstead of repeateddocument.getElementById('article-container') - Convert
tabsFnto event delegation, binding click listener on$articleinstead of each.tabselement - Convert
clickFnOfTagHideto event delegation, binding on$articleinstead of individual.hide-buttonelements - Rewrite
getActualHeightto usecloneNode(true)+ hidden insertion measurement instead of traversing parent nodes and modifying styles - Change Traditional/Simplified Chinese lookup from
indexOftoMap.has/Map.getfor O(1) lookups - Defer Chinese character mapping initialization (
getMaps) to avoid unnecessary computation - Change
translateButtonObjectintw_cn.jstolet, supporting re-query after pjax - Refactor Mermaid gesture system: use
AbortControllerfor event listener lifecycle management to prevent duplicate bindings; addstopPropagationto wheel events to prevent scroll pass-through; cachegetBoundingClientRectwith dirty flag; batch DOM updates viarequestAnimationFrame; normalizedeltaModefor cross-browser compatibility - Reduce Mermaid image preview
revokeObjectURLtimeout from 30s to 5s - Switch MathJax to
ui/lazymodule for deferred rendering, removing therenderActions.findScripthack - Change MathJax re-render to use
typesetClear+typesetPromiseinstead oftexReset - Extract
resolvePostAssetas independent function inrandom_cover.jsto reduce duplication - Change
getVersioninpage.jsto referencethemeVersionfrom module-levelrequire, avoiding repeatedpackage.jsonreads - Fix darkmode time range judgment in
inject_head_js.jsfor cross-midnight scenarios (start > end)
Bug Fixes
- Fix Traditional/Simplified Chinese button text not updating after pjax (
translateButtonObjectchanged toletand re-queried intranslateInitialization) - Fix
script[data-pjax]replacement failure after pjax completion (additem.parentNodeexistence check) - Fix
responseURLpotentially beingundefinedin pjax error handling, add null checks - Fix
handleThemeChangecrash whenthemeChangeis not an object (addtypeof fn !== 'function'check) - Fix
scrollFnwherecheckDocumentHeight()returning early prevented scroll event binding - Fix Mermaid chart jumping on scroll in Chrome (
svg.style.touchAction = 'none'+preventDefault+stopPropagationon wheel events) - Fix Mermaid gesture handlers binding repeatedly after themeChange/pjax (replace
__mermaidGestureBoundflag with__mermaidAbortControllercleanup) - Fix Mermaid configuration parse failure with no error feedback (add try/catch)
- Fix
gallery.jsIMAGE_REGEXlastIndexnot resetting on repeated calls - Fix XSS vulnerability in
flink.jsandbutton.jsdue to missing HTML escaping - Fix
hide.jsparseArgsmissing trim, causing parameters to have leading spaces - Fix
series.jsmodule-level mutablegroupsstate accumulating stale data across builds (addbefore_generatecleanup) - Fix
score.jsduplicatingescapeHTMLimplementation, switch tohexo-util'sescapeHTMLwith additional{}handling - Fix
getArchiveLength.jsyear count not accumulating inmonthlymode - Fix
getArchiveLength.jskey selection logic sodailymode correctly retrieves month counts - Fix
related_post.jscomputingpostDescprematurely; defer to render time - Fix
page.jstimezone variable scope issue inshuoshuoFN - Fix
page.jscloudTagsremoving redundantcolorClassvariable and class - Fix
page.jsfindArchivesTitlerecursion wherem[key]might not be a string - Fix
main.jsfetchUrlsilently returning empty array on HTTP failure; now throws error - Fix
main.jsrunJustifiedGalleryedge case handling whenlimit/firstLimitare invalid values - Fix
main.jsaddJustifiedGalleryerror handling whendatais not an array - Fix
main.jssanitizeStringfrom only replacing"to replacing&,",',<,>characters - Fix
main.jsforPostFnskipping initialization whenhbe-containerexists - Fix
main.jsgallery showing loading animation when data is empty
Changed
- Mermaid gesture zoom from fixed factor (1.1/0.9) to continuous factor (
Math.pow(1.001, delta)) for smoother operation - Mermaid gesture viewBox bounds from computed on each move to pre-calculated
minW/maxW/minH/maxH - Remove unnecessary
typeof svg === 'string'branch in MermaidopenSvgInNewTab - Set MathJax
lazyMarginto200px - Change
adjustMenuhideMenuIndexfrom inline to pre-declared - Change
scrollFnisChatBtntotypeof window.chatBtn !== 'undefined' - Change
scrollFninnerHeightto dynamically computewindow.innerHeight + 56on each scroll
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
