It depends what static site generator you are using.
For Jekyll, for instance, you have the plugin gjtorikian/jekyll-last-modified-at, a liquid tag for Jekyll to indicate the last time a file was modified.
This plugin determines a page's last modified date by checking the last Git commit date of source files.
In the event Git is not available, the file's mtime is used.
With Hugo, you have the lastmod Git variable, that you can configure (as shown in "Last Modified Date with Hugo" by Andrew Stevens , or in "Last Modified Date in Hugo" from MERT BAKIR)
[frontmatter]
enableGitInfo = true
date = ["date", "publishDate", "lastmod"]
lastmod = ["lastmod", ":git", "date", "publishDate"]
By default, :git comes before lastmod but the configuration change above allows you to still define lastmod in your front-matter to override git derived dates if you wish.
You can now display lastmod:
<p>Last Modified: {{ .Lastmod.Format "2 January 2006" }}</p>
With 11ty/eleventy, you would use contentDate: see issue 330.
The goal is, of course, to not use a dynamic script (with API call) in your page, since it would involve an API call each time you access the page.
The "last modification" should be a static data, generated once when you are building and publishing your page.