2

I am embedding Vue.js into an existing application.

When initializing Vue.js like so:

new Vue({
    el: "#myDomElement",
    data: myData,
    computed: {
        price: function() { 
            return _this.productPrice(); 
        },
    },
    created: function() { console.log("Vue created."); },
    beforeCompile: function() { console.log("Vue about to compile."); },
    compiled: function() { console.log("Vue compiled."); },
    ready: function() { console.log("Vue ready."); },
});

I am getting a lag of about 10 seconds at this point in my code. After this delay the lifecycle hooks (created, beforeCompile etc.) all fire at once.

The delay is independent of the view, even if myDomElement is an empty div the delay occurs.

Might be relevant:

  • The myData object is not small but not huge either (28KB when JSON.stringified)

  • The Vue.js initialization happens in a module, that is exported via modules.export and then wrapped up by Webpack

10
  • Please add the module code for further inspection. Commented Apr 15, 2016 at 12:36
  • @AaronFranco Thanks for having a look at it. I updated the question. Commented Apr 15, 2016 at 13:38
  • How do you know Vue is the bottleneck? With 2k lines of code, there could potentially be many possibilities for the bottleneck. Commented Apr 15, 2016 at 13:40
  • @AaronFranco The delay occurs if the new Vue({...}); statement is there, the delay does not occur when this statement is removed, which indicates that Vue is at least involved in the delay. Commented Apr 15, 2016 at 13:46
  • Maybe you can work with this to reproduce the issue: jsfiddle.net/aaronfranco/yMv7y/1456 Commented Apr 15, 2016 at 13:52

1 Answer 1

4

It turned out the data object myData was too complex (and it was significantly larger than stated by me in the original post).

The Vue.js documentation states

It is not recommended to observe complex objects.

see Vue.js docs

We were able to move some data of the myData object to another object with no data binding and get the application running smoothly again.

Sign up to request clarification or add additional context in comments.

1 Comment

This may have indirectly resolved an issue I was having in my own application. Upvoted for the documentation quote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.