JavaScript littered throughout templates, breaks custom templates on upgrade #2267

Closed
opened 2025-11-02 04:30:27 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @coolaj86 on GitHub (Aug 29, 2018).

Description

Related to https://github.com/go-gitea/gitea/issues/4168

The JavaScript is really messy. There are 12 scripts that load on the issues page, plus JavaScript embedded int HTML (for example see templates/base/footer.tmpl).

This makes the templates extremely fragile when using custom templates and prone to causing unexpected errors between minor upgrades (which shouldn't break).

I'd suggest three things:

  • Keep it clean. ABSOLUTELY NO JavaScript in the html and no html in the JavaScript (unless a person customizing their template decides to). There are 3 frameworks being loaded, let's just put those to use.
  • All JavaScript tags moved into its own template that could be included by the templates a person would edit
  • Preferably concatenate all of the JavaScript into a single file and hard cache it (don't require a 304) with a version identifier in the template for cache-busting <script src="/all.js?v{{AppVer}}"></script>
    • The one exception that should probably only be included where it's actually needed is highlight.pack.js since it's large enough to cause vm compile pauses on mobile.
    • Some people believe that it's better to split out frameworks and such into their own files for caching, but this adds roundtrip latency and is only particularly helpful if you're using CDNs improperly to start with and expecting them to hard-cache, which they typically don't. In this case that's not happening so literally the only advantage of multiple files is lazy loading, which isn't being done presently.

Screenshots

screen shot 2018-08-28 at 9 41 38 pm

Thoughts?

I'd be willing to dig around a little bit and see what could be done to improve this.

Originally created by @coolaj86 on GitHub (Aug 29, 2018). - Gitea version (or commit ref): v1.4.x, v1.5.0 - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) See https://github.com/go-gitea/gitea/issues/4168 ## Description Related to https://github.com/go-gitea/gitea/issues/4168 The JavaScript is *really* messy. There are 12 scripts that load on the issues page, plus JavaScript embedded int HTML (for example see `templates/base/footer.tmpl`). This makes the templates extremely fragile when using custom templates and prone to causing unexpected errors between minor upgrades (which shouldn't break). I'd suggest three things: * Keep it clean. ABSOLUTELY NO JavaScript in the html and no html in the JavaScript (unless a person customizing their template decides to). There are 3 frameworks being loaded, let's just put those to use. * All JavaScript tags moved into its own template that could be included by the templates a person would edit * Preferably concatenate all of the JavaScript into a single file and hard cache it (don't require a 304) with a version identifier in the template for cache-busting `<script src="/all.js?v{{AppVer}}"></script>` * The one exception that should probably only be included where it's actually needed is `highlight.pack.js` since it's large enough to cause vm compile pauses on mobile. * Some people believe that it's better to split out frameworks and such into their own files for caching, but this adds roundtrip latency and is only particularly helpful if you're using CDNs improperly to start with and expecting them to hard-cache, which they typically don't. In this case that's not happening so literally the only advantage of multiple files is lazy loading, which isn't being done presently. ## Screenshots ![screen shot 2018-08-28 at 9 41 38 pm](https://user-images.githubusercontent.com/122831/44764650-0a918180-ab0e-11e8-9ea6-4f458bad0a40.png) ## Thoughts? I'd be willing to dig around a little bit and see what could be done to improve this.
GiteaMirror added the issue/staletype/refactoring labels 2025-11-02 04:30:27 -06:00
Author
Owner

@stale[bot] commented on GitHub (Jan 11, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 11, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@stale[bot] commented on GitHub (Feb 21, 2019):

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale[bot] commented on GitHub (Feb 21, 2019): This issue has been automatically closed because of inactivity. You can re-open it if needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2267