I have been working on a Rails application and have integrated some Vue components into the pages. The components range from simple dynamic lists to more complex implementations with nested components.
Let me walk you through how it all functions with some code examples.
Here's a snippet of code from the main layer of a Rails application:
body
#app
= yield
And now, a snippet of code from the JavaScript side:
if (document.getElementById('app')) {
new Vue({
el: '#app',
However, I've been facing an issue lately. Sometimes, when I open the browser, the page loads without the Vue components. This issue seems to occur on both macOS Chrome/Safari and iOS Safari. Strangely enough, manually reloading the page seems to solve the problem.
What could be causing this issue? Why does the browser quickly load the page after launch (possibly from a cache) and struggle to render the Vue components properly?