You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.3 KiB

4 years ago
  1. +++
  2. title = "JIT Requests"
  3. description = "Maximize resources while minimizing external requests."
  4. categories = ["experience"]
  5. tags = ["performance", "styles", "javascript"]
  6. features = ["related content", "snippets", "code highlighter"]
  7. [[copyright]]
  8. owner = "Josh Habdas"
  9. date = "2019"
  10. license = "agpl-3.0-or-later"
  11. +++
  12. After Dark makes <abbr title="Just-In-Time">JIT</abbr> requests for some external assets to cut down on resource consumption and increase page performance.
  13. Take the [Code Highlighter](../code-highlighter) stylesheet for example:
  14. {{< highlight css >}}
  15. {{< include "themes/after-dark/static/css/syntax.css" >}}
  16. {{< /highlight >}}
  17. The stylesheet code shown above is itself highlighted using a JIT request. Confirm by viewing the network requests for this page and observe the `fetch` request for the `syntax.css` file as depicted here:
  18. ```sh
  19. jit-requests (document)
  20. ├── lazysizes.min.js (fetch)
  21. ├── syntax.css (fetch)
  22. ```
  23. Using [Fetch Injection](../fetch-injection) a JIT request is issued to begin downloading the highlighter stylesheet on-the-fly in parallel with other resources and the base layout takes care to ensure the CSS is only requested on pages that need it.
  24. Create your own JIT requests using [Custom Layout](../custom-layouts) and [Fetch Injection](../fetch-injection).