Skip to content

Unit 12: widget partials — extract inline JS, add SRI, i18n labels#14

Open
stradichenko wants to merge 1 commit intomainfrom
unit-12-widget-partials-extract-inline-js
Open

Unit 12: widget partials — extract inline JS, add SRI, i18n labels#14
stradichenko wants to merge 1 commit intomainfrom
unit-12-widget-partials-extract-inline-js

Conversation

@stradichenko
Copy link
Copy Markdown
Owner

Summary

For each of: zipfs-law, lda-analysis, knowledge-graph, filters, gallery-slider, contribution-calendar:

  • Move inline <script> blocks into assets/js/<widget>.js (created where missing). Pass per-page data via inline <script type="application/json" id="<widget>-data"> blocks read by the JS on init.
  • Bundle each widget JS with js.Build | minify | fingerprint and defer. Add SRI integrity (or self-host) for D3, TensorFlow.js, mermaid.
  • i18n widget labels (Activity Calendar, Less / More, Physics Controls, Repulsion, Reset to Default, All Nodes, Save as PNG/SVG/JPEG, LDA / Zipf labels) with English fallback.
  • zipfs-law: replace the template-driven allWords.push("...") loop (~36 lines) with a single jsonify dump in a <script type="application/json"> block.
  • gallery-slider: extract the 460-LOC inline GallerySlider ES6 class into assets/js/gallery-slider.js.
  • Wire assets/js/contribution-calendar.js back in (it was effectively dead before).

Notes for reviewer

  • ⚠️ Conflicts with Unit 15: Unit 15 deletes assets/js/contribution-calendar.js thinking it's dead. Resolve by keeping the file (Unit 12 wires it).

Test plan

  • Each widget's HTML contains a single <script src="...fingerprint..."> referencing the widget JS.
  • /about/ (zipf), any post (sidenote/citation), and a knowledge-graph-enabled page still load.

Part of the PKB-theme modernization batch (15 units).

For each of: zipfs-law, lda-analysis, knowledge-graph, filters,
gallery-slider, contribution-calendar:

- Move inline <script> blocks into the corresponding
  assets/js/<widget>.js (created where missing). Pass per-page data via
  inline <script type=application/json id=<widget>-data> blocks read by
  the JS on init.
- Bundle each widget JS with js.Build | minify | fingerprint and defer.
- Add SRI integrity (or self-host) for D3, TensorFlow.js, mermaid.
- i18n widget labels (Activity Calendar, Less / More, Physics Controls,
  Repulsion, Reset to Default, All Nodes, Save as PNG/SVG/JPEG, LDA and
  Zipf labels) with English fallback.
- zipfs-law: replace the template-driven allWords.push("...") loop
  (~36 lines) with a single jsonify dump in a
  <script type=application/json> block.
- gallery-slider: extract the 460-LOC inline GallerySlider ES6 class
  into assets/js/gallery-slider.js.
- Wire assets/js/contribution-calendar.js back in (it was effectively
  dead before).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant