Skip to content

Commit

Permalink
Load asciicast css async (#22502)
Browse files Browse the repository at this point in the history
Load asciicast css asynchronously.

Related to #22448.
  • Loading branch information
wolfogre committed Jan 18, 2023
1 parent 326d29d commit 4804900
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 4 additions & 1 deletion web_src/js/markup/asciicast.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ export async function renderAsciinemaPlayer() {
const els = document.querySelectorAll('.asciinema-player-container');
if (!els.length) return;

const player = await import(/* webpackChunkName: "asciinema-player" */'asciinema-player');
const [player] = await Promise.all([
import(/* webpackChunkName: "asciinema-player" */'asciinema-player'),
import(/* webpackChunkName: "asciinema-player" */'asciinema-player/dist/bundle/asciinema-player.css'),
]);

for (const el of els) {
player.create(el.getAttribute('data-asciinema-player-src'), el, {
Expand Down
2 changes: 0 additions & 2 deletions web_src/less/markup/asciicast.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import "../asciinema-player/dist/bundle/asciinema-player.css";

.asciinema-player-container {
width: 100%;
height: auto;
Expand Down

0 comments on commit 4804900

Please sign in to comment.