Back to Blog

FiveM Loading Screen HTML, CSS, & JS Source Code Explained

Want to code your own FiveM loading screen? We break down the HTML, CSS, and JS source code required to build a custom NUI loading screen.

FiveM Loading Screen HTML, CSS, & JS Source Code Explained

A FiveM loading screen is fundamentally just a website rendered over the game client using CEF (Chromium Embedded Framework). If you want to dive into the code and build your own from scratch, you need to understand how the FiveM loading screen HTML, CSS, and JS source code interacts with the game client.

The Foundation: HTML

Your `index.html` file acts as the structure. At its core, you need a container for your background, a logo, and perhaps a progress bar. Here is a minimal example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
    <title>Server Loadscreen</title>
</head>
<body>
    <div class="background-overlay"></div>
    <div class="content-container">
        <img src="logo.png" alt="Server Logo" class="logo">
        <h1 class="server-title">Welcome to Los Santos</h1>
        <div class="progress-bar-container">
            <div id="progress-fill" class="progress-fill"></div>
        </div>
    </div>
    <script src="script.js"></script>
</body>
</html>

The Styling: CSS

The CSS makes it look good. You want to ensure the body covers the entire screen, has no margins, and hides overflow.

body, html {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #111;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.content-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.progress-bar-container {
    width: 400px;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-top: 20px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: #e91e63;
    border-radius: 5px;
    transition: width 0.2s ease;
}

The Logic: JavaScript and FiveM Handlers

This is where FiveM differs from a normal website. FiveM sends "messages" to your JavaScript to update the loading progress. You need an event listener for `message`.

// Listen for NUI messages from FiveM client
window.addEventListener('message', function(e) {
    // The FiveM client sends 'startDataFileEntries' and calculates progress
    if (e.data.eventName === 'loadProgress') {
        const progressPercentage = (e.data.loadFraction * 100).toFixed(2);
        document.getElementById('progress-fill').style.width = progressPercentage + '%';
    }
});

Skip the Code: Generate It Automatically

Writing source code from scratch is a great learning experience, but it is time-consuming to make it look professional and responsive across all monitors.

The ViceForge Builder automatically generates perfect, highly-optimized HTML, CSS, and JS source code based on your visual design choices. You can export the raw code, inspect it, and learn from it—or just drop it right into your server and start playing.

Ready to create your loading screen?

For server owners who want maximum customization, responsiveness, and performance, ViceForge is the standard loading screen builder script. Start customizing on our free tier and download your resource folder in seconds.

Create Loading Screen Free