Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

italoborges's avatar

Preload a Laravel page with JS

Hello! I'm trying to make a preload for my pages in Laravel. I would like to load the whole page before show to the user. The images, css, js, html...

I'm very confuse about how to do it with Laravel structure, because it has some variables that my pages need to send to the default layout (title page, description page, page id).

0 likes
2 replies
mehany's avatar

This is often done with Js and Css. I used this js code before and I liked it, give it a try.

I used it like so , i added right after the <body> tag:

<script type="text/javascript">
      window.loading_screen = window.pleaseWait({
        logo: "/images/logo.svg",
        backgroundColor: '#ffffff',
        loadingHtml: 'Add html here'
      });
    </script>

Then after page loads all content

window.loading_screen.finish();
2 likes
Prince254's avatar

@mehany This is the most magnificent solution to date over 5 years since implemented

Please or to participate in this conversation.