mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 08:37:43 +01:00
Minifies tgui helpers (#90340)
## About The Pull Request Instead of just writing out the helper functions and styles directly inside tgui.html, this minifies them and injects them into the document on tgui init. The result should be a smaller bundle and more manageable code, with clear separation of page, style, and javascript ## Why It's Good For The Game Minification is generally a small perf gain but I want to be clear that I'm doing this 100% for organization & separation of concerns ## Changelog N/A
This commit is contained in:
@@ -26,12 +26,24 @@ SUBSYSTEM_DEF(tgui)
|
||||
|
||||
/datum/controller/subsystem/tgui/PreInit()
|
||||
basehtml = file2text('tgui/public/tgui.html')
|
||||
|
||||
// Inject inline helper functions
|
||||
var/helpers = file2text('tgui/public/helpers.min.js')
|
||||
helpers = "<script type='text/javascript'>\n[helpers]\n</script>"
|
||||
basehtml = replacetextEx(basehtml, "<!-- tgui:helpers -->", helpers)
|
||||
|
||||
// Inject inline ntos-error styles
|
||||
var/ntos_error = file2text('tgui/public/ntos-error.min.css')
|
||||
ntos_error = "<style type='text/css'>\n[ntos_error]\n</style>"
|
||||
basehtml = replacetextEx(basehtml, "<!-- tgui:ntos-error -->", ntos_error)
|
||||
|
||||
// Inject inline polyfills
|
||||
var/polyfill = file2text('tgui/public/tgui-polyfill.min.js')
|
||||
polyfill = "<script>\n[polyfill]\n</script>"
|
||||
polyfill = "<script type='text/javascript'>\n[polyfill]\n</script>"
|
||||
basehtml = replacetextEx(basehtml, "<!-- tgui:inline-polyfill -->", polyfill)
|
||||
basehtml = replacetextEx(basehtml, "<!-- tgui:nt-copyright -->", "Nanotrasen (c) 2525-[CURRENT_STATION_YEAR]")
|
||||
|
||||
|
||||
/datum/controller/subsystem/tgui/Shutdown()
|
||||
close_all_uis()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user