Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Vue js : Multiple instance VS Single instance but template from HTML, what is the best practice for performances

I have seen some questions in stackoverflow about that subject, but they never really mentioned performances.

Let's say that I have HTML page with a list of Shop, this HTML list is generated by the server in the page HTML.

I would like for each Shop HTML "block" to display a Vue JS <Calendar /> component

HTML :

<div class="list">
  <div class="shop">
    <div>
      <div>
        <div>
          <div>
           <div class="component-placeholder" data-shop-id="x"></div>
    ....
  </div>
  <div class="shop">
    <div>
      <div>
        <div>
          <div>
           <div class="component-placeholder" data-shop-id="x"></div>
    ....
  </div>
  ...
</div>

For JS there is 2 possibility.

Option 1 :

document.querySelectorAll('.component-placeholder').forEach((item) => {
  const shopId = item.getAttribute('data-shop-id');
  new Vue({
    render: (h) => h(Calendar, {
      props: {
        shopId,
      },
    }),
  }).$mount(item);
});

Option 2 :

const elem = document.querySelector('.list');
new Vue({
  el: elem,
  components: {
    Calendar
  },
});

// for this I would replace the component-placeholder with <Calendar shop-id="x" /> in the HTML

My question is, what is the best practice when focusing on performance ?

If the list has 30 Shop, Option 1 would create 30 instance of Vue living together, but Option 2 would also need to add and create all the HTML elements inside its shadow DOM when the component is first loading no ?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!