Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render special blockquotes on the backend #351

Merged
merged 3 commits into from
Jul 16, 2024
Merged

Render special blockquotes on the backend #351

merged 3 commits into from
Jul 16, 2024

Conversation

timacdonald
Copy link
Member

@timacdonald timacdonald commented Jul 15, 2024

This PR moves the rendering of the pretty "highlight" blockquotes to the backend. Currently, there is a slight visible flicker and content shift for all blockquotes.

In addition to pushing the rendering to the backend, it also inlines the highlight images as inline SVGs. This reduces the requests needed to be made to render a page. The images are very small and we also use GZIP, so inlining them really has no impact on HTML load times.

Overall, this should also have a positive impact on load / interactive times.

Flicker example

Screen.Recording.2024-07-16.at.09.00.06.mov

How it works

Currently, we ship the raw blockquote content to the frontend:

<blockquote>
    <p>[!NOTE]<br />
    New to Laravel? Check out...</p>
</blockquote>
Screenshot 2024-07-16 at 08 57 29

Once the DOM has loaded into the browser, we then manipulate the DOM and update the blockquotes to their fancy version.

<blockquote>
    <div class="mb-10 max-w-2xl mx-auto px-4 py-8 shadow-lg lg:flex lg:items-center callout">
        <div class="w-20 h-20 mb-6 flex items-center justify-center shrink-0 bg-purple-600 lg:mb-0">
            <img src="/img/callouts/lightbulb.min.svg" height="40" width="28" loading="lazy" class="opacity-75">
        </div>
        <p class="mb-0 lg:ml-6">
            New to Laravel? Check out ...
        </p>
    </div>
</blockquote>
Screenshot 2024-07-16 at 08 57 10

This causes the flicker. Now we just deliver the fancy highlight in the HTML delivered to the browser.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This asset is no longer referenced.

Comment on lines -28 to +42
$environment->addExtension(new GithubFlavoredMarkdownExtension());
$environment->addExtension(new AutolinkExtension());
$environment->addExtension(new StrikethroughExtension());
$environment->addExtension(new TableExtension());
$environment->addExtension(new TaskListExtension());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've inlined the extensions previously added in the extracted GithubFlavoredMarkdownExtension class.

Comment on lines -60 to -62
case "laracasts":
case "video":
return ['/img/callouts/laracast.min.svg', 'bg-blue-600', 49, 40];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "laracasts" tag does not appear in the docs anymore. Only "video" does.

@timacdonald timacdonald marked this pull request as ready for review July 15, 2024 23:09
@taylorotwell taylorotwell merged commit f3e245e into master Jul 16, 2024
1 check passed
@taylorotwell taylorotwell deleted the blockquote branch July 16, 2024 13:53
@timacdonald timacdonald mentioned this pull request Aug 26, 2024
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