Vue: Load page content only after the route change is complete

Every time I visit a new route within the current session, I notice that the page loads and then takes about 2 seconds for the styles to be applied. This delay causes what is commonly known as CSS flashing or FOUC (Flash of Unstyled Content), which ultimately negatively impacts the user experience.

To resolve this issue, my best solution would be to ensure that the page only renders once it has fully loaded.

Does anyone have any suggestions on how to achieve this?

Furthermore, there are some other CSS-related issues that may be connected to the previous problem:

You can see a live example of this issue here:

When clicking on "Name Search" or "Weight Table", you'll notice that the page content is rendered before the CSS is applied. This behavior doesn't occur with the other two pages where no CSS frameworks are attached. It seems like the presence of CSS frameworks might be causing these issues, but how can this be addressed?

Another concern is that when refreshing the "Name Search" or "Weight Table" pages, the CSS framework fails to load properly, while the standard CSS does load correctly.

It appears that both of these issues stem from the usage of CSS frameworks since the pages without them function correctly.

Would anyone happen to know of any potential fixes or workarounds for these issues?

Here's an overview of how my components are structured, using "Weight Table" as an example:

<template>
<div class="weightconverter-wrapper">

    <div class="container">
    
    <div class="row">
    
        <div class="col-md-6 offset-md-3">
        
        <h1 class="display-4 text-center mb-3"> Weight Converter </h1>
            
            <form>
            
                <div class="form-group">
                
                    <input type="number" class="form-control form-control-lg" id="filter" placeholder="Input weight..." @input="calculate">
                    
                </div>
                
            </form>
            
            <div id="results">
            
            </div>
            
        </div>
        
    </div>
    
    </div>
    
</div>
</template>

....(remaining component code)....

</style>

Note: The issue with reloading only occurs on the remote server; local reloading works fine (though there is still a FOUC).

PS2 - Just wanted to mention that the project was generated using "npm run generate".

Answer №1

To display content only when the data is fully loaded, consider implementing conditional rendering in your Vue.js application. Check out this helpful guide for more information: https://v2.vuejs.org/v2/guide/conditional.html

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enrollment of Vue components

After importing the component into the JavaScript file, I added it to the index.vue file as follows: import fmsSubUnitDetails from '../subunitDetails'; export default{ components: { fmsSubUnitDetails }, } Despite this, I am still encount ...

Maintain synchrony of the state with swiftly unfolding occurrences

I developed a custom hook to keep track of a state variable that increments based on the number of socket events received. However, when I tested by sending 10 simultaneous events, the total value of the state variable ended up being 6, 7, or 8 instead of ...

Changing HTML elements dynamically within an ng-repeat using AngularJS directives

I have devised an angular directive where I execute an ng-repeat. The fundamental purpose of this directive is to interchange itself with a distinct directive that depends on a value forwarded into the original directive: <content-type-directive type=" ...

toggle between utilizing the page object API and the primary Nightwatch API

Currently, I am incorporating the page object model alongside nightwatch for my testing procedures. Encountering challenges while trying to interact with an element led me to execute some jquery. However, the 'execute' command is not featured in ...

JS Data error: The attributes provided must include the property indicated by idAttribute - particularly with regards to hasMany relationships

Encountered Error: The main key for my user model is username. The primary key for my routes is the routename. When my API returns JSONs, they are nested inside data:{} following jsonapi.org specifications. However, this structure differs from what js-dat ...

Slick Slider - Defining the Initial Slide

My website features a dynamic carousel showcasing a basketball team's schedule, with games sorted by date for the current season. I am trying to align the slider to display the upcoming game at the center. How can I designate a specific slide as the ...

What is the method for obtaining multiple indices on an Array?

Attempting to find multiple index positions in an Array for a Boolean value. Experimenting with while and for loops to iterate through more than one index position without success so far. Below is the code snippet: let jo = [1,2,3,4,5] let ji = [1,2,3] ...

Strip certain tags from HTML without including iframes

Removing specific tags from HTML can be tricky, especially when working with PHP and JavaScript. One approach is to fetch an HTML page in a PHP file using curl and getJSON, storing the result in a .js file. However, this method may encounter issues with mu ...

Vue.js parent component sending new data: prop mutation detected

Encountering an issue in the console with the following error message: Instead, use a data or computed property based on the prop's value. Prop being mutated: "sortType" Within my root file, I have an API and filter function sending data to comp ...

Using Ember's transitionTo method and setting a controller attribute within a callback

I am working with Ember code to transition to a specific route while also setting controllerAttr1 on 'my.route' Upon transitioning to "my.route" using this.get('router').transitionTo("my.route"), I have set up a callback function that ...

Error: The function 'fetch' is not recognized in Selenium Console

Having some trouble with Selenium and Chrome Developer Tools. I want to open Selenium, go to a URL, and then use driver.execute_script to make a fetch request via Console in Chrome Developer Tools within the Selenium window. However, when I try to run thi ...

Having trouble with an AJAX request to display a template in Flask

Imagine having two radio buttons labeled 1 and 2, along with some text at the bottom of a webpage. Initially, the text value is set to -1 and no radio buttons are selected. If one of the radio buttons is clicked, the text value should change to either 1 or ...

Transferring files with Node.js via UDP connections

I'm currently working on setting up a basic Node.js server that is designed to receive files from clients through UDP. The challenge I'm facing is that whenever I attempt to send a large file (anything over 100kb), the server appears unresponsive ...

Unable to modify the appearance of an HTML element when injected via a Chrome extension

I am currently developing a unique chrome extension that uses Ajax to inject custom HTML into the current tab. This extension appends a <div> element to the body, and now I need to manipulate it using JavaScript. Specifically, I want it to dynamical ...

What are the distinctions between utilizing util.inherits() and prototypes for inheritance in node.js?

The method util.inherits() allows for the inheritance of methods from one function to another. Prototypes are also a way to achieve inheritance in JavaScript. I am wondering when it is best to use .inherits() versus changing the prototype chain. Any advi ...

Shopping cart feature in PHP - Ajax response only functioning once

I'm in the process of developing a shopping cart. I start by adding products to the cart, then use Ajax to dynamically update the quantity when it changes. Everything works smoothly after the first change, but subsequent quantity updates do not refres ...

Utilize three.js within a Google web app script - unable to incorporate the script module type for loading three.js

Looking to incorporate three.js into a Google Web Script to load 3D CAD files, I discovered that the installation instructions on threejs.org specify the script needs to be of "module" type. However, after researching for several days, it seems that Google ...

Is it possible to customize the behavior of ESLint to automatically run when saving a file after installation with the "on commit" option?

Perhaps my vision is failing me, as I cannot seem to find any information about this issue on or https://eslint.org/. Should I consider the drastic step of uninstalling and reinstalling it? ...

Understanding the proper way to enclose JSX components and exhibit JSON based on user input

I'm currently working on a university administration website using React that needs to support multiple languages. I have successfully built the Login page, which you can see here: https://i.stack.imgur.com/cIiaU.png Now, my next task is to allow us ...

What is the proper way to utilize --legacy-peer-deps or enforce in a vite build?

I encountered an issue with a package called react-typed in my project. To install it, I had to use --legacy-peer-deps. When deploying, I need to use vite build. However, when I run the command, I receive the following errors: 8:59:31 AM: npm ERR! node_mo ...