Skip to content

moment.js loaded globally but only used in search #785

@Parth-Garg2629

Description

@Parth-Garg2629

Page URL

https://precice.org

What is wrong?

moment.js (~17KB) is loaded unconditionally on every page of the website via _includes/head.html (line 101), but it is only ever used in one place: _includes/algolia.html (line 20), to format a date string in search results.

Current behaviour: Every visitor downloads moment.js regardless of whether they interact with the search widget at all.

Expected behaviour: moment.js should only be loaded as a dependency of the search widget (algolia.html), not as a global resource in <head>.

Proposed fix:

  • Remove the <script src="...moment.min.js"> tag from _includes/head.html
  • Add it at the top of _includes/algolia.html, directly before the inline script that consumes it

This is a one-file-change with zero risk of breakage since moment has exactly one call site.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GSoCContributed in the context of the Google Summer of CodetechnicalTechnical issues on the website

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions