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
What src to specify in an iframe... in a custom element... in a published package?

I have turned a Flutter web app into custom element, which I am publishing as an npm package.

The output of a Flutter web build is a html file (within which some scripts are run), so a quick way to turn this is a custom element is to wrap it in an iframe. The custom element has the general form:

class CustomElement extends HTMLElement {
    constructor() {
        super();
        this.innerHTML = `
            <iframe src="src/flutter_output.html"></iframe>`; 

Running on localhost, no problem.

Published to npm, yes problem.

This is because the src path in the iframe is relative to the home dir of the users index.html, so if the user has installed the package locally, the src should be something like "./node_modules/@package/flutter_output.html" (hard-coding where the package file will be feels dangerous). Or if they are using unpkg, then presumably the src would link back to unpkg, e.g. unpkg.com/package/flutter_output.html (and this seems wasteful).

So the question is what src do I use in the iframe? Or is there another solution to this issue? I am new to web dev, so could quite easily have overlooked something.

A possible solution could be to lose the iframe and html entirely, by converting the flutter_output.html to javascript. Although this could be very painful.

about 4 years ago · Santiago Trujillo
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!