Load Bootstrap once per skin#122
Closed
malberts wants to merge 1 commit into
Closed
Conversation
malberts
force-pushed
the
bootstrap-js-single-copy
branch
3 times, most recently
from
July 20, 2026 19:51
d9d63f2 to
6de6a7f
Compare
malberts
force-pushed
the
bootstrap-js-single-copy
branch
4 times, most recently
from
July 20, 2026 20:26
68a0fee to
bec0cc6
Compare
Skins that bundle their own Bootstrap (Medik, Tweeki) also received Extension:Bootstrap's copy, because BootstrapComponents loaded ext.bootstrap.styles and ext.bootstrap.scripts unconditionally. That put two copies of Bootstrap on the page: two stylesheets, whose cascade left stray list bullets on the skin's sidebar and dropdown menus, and two scripts, each registering Bootstrap's document data-api, so navbar and action dropdowns opened and immediately closed. BootstrapComponents is the extension that pulls in Extension:Bootstrap, so it decides when that is needed: it loads Extension:Bootstrap's Bootstrap only on skins that do not provide their own (BootstrapProvider), from a BeforePageDisplay hook where the active skin is known, and only where a page parsed BootstrapComponents content. Extension:Bootstrap stays an honest, unconditional provider. Component initialisation goes through a small shared module (ext.bootstrapComponents.bootstrap) that finds whichever Bootstrap is on the page: the window.bootstrap global, or the jQuery plugin bridge that some skins expose instead (a plugin's Constructor is the native component class). It runs on wikipage.content, so it also covers dynamically rendered content. Because the load moved off the ParserOutput (so the decision can depend on the skin, which the shared parser cache cannot), api.php?action=parse no longer lists ext.bootstrap.styles / ext.bootstrap.scripts. Page views, VisualEditor and live preview are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
malberts
force-pushed
the
bootstrap-js-single-copy
branch
from
July 20, 2026 20:29
bec0cc6 to
fd53cfa
Compare
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #70
Skins that bundle their own Bootstrap (for example Medik and Tweeki) also received
Extension:Bootstrap's copy, because BootstrapComponents loaded
ext.bootstrap.stylesandext.bootstrap.scriptsunconditionally. That put two copies of Bootstrap on the page: twostylesheets, whose cascade left stray list bullets on the skin's sidebar and dropdown menus, and
two scripts, each registering Bootstrap's document data-api, so one click was handled twice and the
skin's navbar and action dropdowns opened and immediately closed.
BootstrapComponents is the extension that pulls in Extension:Bootstrap, so it is the right place to
decide when that is needed. It now loads Extension:Bootstrap's Bootstrap only on skins that do not
provide their own (
BootstrapProvider::skinProvidesBootstrap), from aBeforePageDisplayhookwhere the active skin is known. On a skin that ships its own Bootstrap, nothing extra is loaded, so
there is a single copy. Extension:Bootstrap is unchanged and stays an honest, unconditional
provider.
Component initialisation goes through a small shared module (
ext.bootstrapComponents.bootstrap)that finds whichever Bootstrap is on the page: the
window.bootstrapglobal thatExtension:Bootstrap and most Bootstrap skins expose, or the jQuery plugin bridge that some skins
register instead (a plugin's
Constructoris the native component class). No skin's own module nameis referenced, the init calls read as plain Bootstrap (
Carousel.getOrCreateInstance( element )),and it runs on
wikipage.content, so it also covers dynamically rendered content.Behaviour
Bootstrap still loads on every page that renders parsed content, as before. The
BeforePageDisplayhook adds it only when the page parsed BootstrapComponents content (the same scope in which the
parser hook runs), so pages that render no wiki content, such as most special pages, are unaffected,
exactly as before.
One deliberate change: the load moved off the
ParserOutput(it has to, so the decision can dependon the skin, which the shared parser cache cannot), so
api.php?action=parseno longer listsext.bootstrap.styles/ext.bootstrap.scriptsin its module lists. Ordinary page views,VisualEditor and live preview are unaffected, since they render on a page that already loads
Bootstrap. Only a headless consumer that renders BootstrapComponents content fetched through
action=parse, outside a page, would need to load Bootstrap itself.Verification
Automated browser testing (Playwright) across Vector, Chameleon, Medik and Tweeki: provider skins
load a single Bootstrap, their sidebar and dropdown menus have no stray bullets, and navbar/action
dropdowns open and stay open; carousel, modal, popover, tooltip and accordion work on all four,
including through the jQuery bridge on Tweeki. A released-vs-branch comparison on Vector confirmed
the page scope matches: content pages, message-parsing special pages and
Special:ExpandTemplatesload Bootstrap; chrome-only special pages do not. Unit tests cover the provider list.