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

188
Views
data- attributes don't work when lazy loading components in svelte

I was lazy loading some components on my svelte applications (followed this guide - https://www.youtube.com/watch?v=eXM0i6qgJyY) but data- attributes don't work on lazy-loaded components.

In my case, I am using Flowbite for popovers but the popovers don't work and upon inspecting the page, I found out that the data- attribute wasn't present in the HTML.

Lazy loading is handled by the following reusable component -

<script>
let loadComponent;
export { loadComponent as this };

const componentPromise = loadComponent();
</script>

{#await componentPromise}
  <slot name="loading">Loading...</slot>
{:then { default: Component }}
  <slot name="component" {Component} />
{/await}

For components being lazy loaded, this is how I have coded it -

<Lazy this={() => import("../components/blog-posts.svelte")}>
  <div slot="loading">Loading</div>
  <svelte:fragment slot="component" let:Component>
    <Component blogPosts={blogData.posts} blogBaseUrl={data.blogBaseUrl} />
  </svelte:fragment>
</Lazy>

The source code for the website - https://github.com/AnishDe12020/portfolio

Would be helpful if someone could let me know if I am going wrong anywhere (maybe there is a better way to lazy load that preserves the data- attributes?)

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!