[FEATURE] Conditional asset loading for tile_maps plugin #2
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
codemacher/tile_maps!2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "gert.hammes.ba/tile_maps:main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds a TypoScript constant that controls whether the extension's CSS and JavaScript assets are loaded globally on every page or only on pages that actually render a tile map.
Motivation
Previously,
MapCreator.css, jQuery, andMapCreator.jswere included on every page of the site viapage.includeCSS/page.includeJSFooter, regardless of whether a map was present. This is unnecessary overhead on pages without a map.Changes
New constant (default
0, fully backward-compatible):0(default)page.includeCSS/page.includeJSFooter— identical to previous behaviour1f:asset.css/f:asset.scriptinside the plugin template, so they are only added to pages that render a mapUpgrade path
No action required for existing installations. To opt in, add to your site TypoScript:
Notes
deferscripts are registered in order (jquerybeforetilemapsmapcreator), guaranteeing correct execution order.How to test
loadAssetsInTemplate = 0(default): verify CSS and JS are present in the page source on all pages, including those without a map.loadAssetsInTemplate = 1: verify CSS and JS are absent on pages without a map and present (before</body>) on pages with a map.looks good