Skip to main content

datasette-total-page-time

PyPI Changelog Tests License

Add a note to the Datasette footer measuring the total page load time

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-total-page-time

Usage

Once this plugin is installed, a note will appear in the footer of every page showing how long the page took to generate.

Queries took 326.74ms · Page took 386.310ms

How it works

Measuring how long a page takes to load and then injecting that note into the page is tricky, because you need to finish generating the page before you know how long it took to load it!

This plugin uses the asgi_wrapper plugin hook to measure the time taken by Datasette and then inject the following JavaScript at the bottom of the response, after the closing </html> tag but with the correct measured value:

<script>
let footer = document.querySelector("footer");
if (footer) {
    let ms = 37.224;
    let s = ` &middot; Page took ${ms.toFixed(3)}ms`;
    footer.innerHTML += s;
}
</script>

This script is injected only on pages with the text/html content type - so it should not affect JSON or CSV returned by Datasette.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-total-page-time
python3 -mvenv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Metadata

Release files for datasette-total-page-time 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-total-page-time 0.1
File Size Uploaded Provenance Actions
datasette-total-page-time-0.1.tar.gz 6.9 kB Without provenance Details for datasette-total-page-time-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datasette-total-page-time 0.1
File Interpreter ABI Platform Actions
datasette_total_page_time-0.1-py3-none-any.whl Python 3 none any Details for datasette_total_page_time-0.1-py3-none-any.whl

Total release size: 14.5 kB

Release files / datasette-total-page-time-0.1.tar.gz

Download URL datasette-total-page-time-0.1.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ca5466fe5d894bdb4cf10b057f2070fdf3789d2af43c7c842ec1c47de344449a
BLAKE2b-256 checksum
How to use checksums
252d432099d52fe682ee227a4cfcdff8018b3647e3428d7de9f43af485deff3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / datasette_total_page_time-0.1-py3-none-any.whl

Download URL datasette_total_page_time-0.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b21682605417bbef4da31b81e1af6233e5126488eaba5b747e51d90392c0fa0
BLAKE2b-256 checksum
How to use checksums
aa20541417048ac6cd326799a4dd8348e86cd50b2512f26e5333e9195fe579b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Security for datasette-total-page-time 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page