Skip to content

Simplify elFinder (dark) mode scripting#90

Merged
pxpm merged 4 commits into
Laravel-Backpack:mainfrom
jnoordsij:simplify-darkmode-scripting
Mar 31, 2026
Merged

Simplify elFinder (dark) mode scripting#90
pxpm merged 4 commits into
Laravel-Backpack:mainfrom
jnoordsij:simplify-darkmode-scripting

Conversation

@jnoordsij
Copy link
Copy Markdown
Contributor

@jnoordsij jnoordsij commented Mar 25, 2026

WHY

BEFORE - What was wrong? What was happening before this PR?

The previous scripting was both somewhat computationally heavy (leveraging lots of loops and regexes) and hard to understand.

AFTER - What is happening after this PR?

In the new script, a simple strategy is applied:

  1. there are two link elements, one for light mode and one for dark mode stylesheets
  2. both are initialized with rel=prefetch, so that the corresponding asset may be fetched if browser supports this directive and prioritizes it at some point, but neither of the stylesheets are 'active'
  3. after detecting current mode and on any subsequent change, the relevant stylesheet is 'activated' by setting rel=stylesheet, while disabling the other by using rel=prefetch

Also some related code has been slightly cleaned up.

HOW

How did you achieve that, in technical terms?

Refactor

Is it a breaking change or non-breaking change?

Non-breaking

How can we test the before & after?

Behavior should remain practically identical

@pxpm
Copy link
Copy Markdown
Contributor

pxpm commented Mar 30, 2026

Hey @jnoordsij care to rebase this so I can give it another look?

Thanks 🙏

@jnoordsij jnoordsij force-pushed the simplify-darkmode-scripting branch from 93e8274 to a4f476e Compare March 30, 2026 10:06
@bassetBlock does not support any way of passing/preserving the type=module attribute yet,
so we should probably be safe here
@jnoordsij
Copy link
Copy Markdown
Contributor Author

@pxpm done! Also slightly adjusted.

@pxpm
Copy link
Copy Markdown
Contributor

pxpm commented Mar 31, 2026

Thanks @jnoordsij 🙏

@pxpm pxpm merged commit 41ef42f into Laravel-Backpack:main Mar 31, 2026
2 checks passed
@jnoordsij jnoordsij deleted the simplify-darkmode-scripting branch March 31, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants