Skip to content

onboarding / FAQ section that also includes notes on how to import items #54

@hanbollar

Description

@hanbollar

Related to issue and solution:

Starting Notes

@lobau @michaelthatsit - it seems to work all fine if we have users define things in the header after the <script src=mrjs> tag - it seems the reason for the issue was:

  • even though we can do async etc of mrjs loading in header with mrfoo in a script after <mr-app> is created, the onload function is needed as part of <script src=mrjs> to connect mr-foo to that part of the loading before any of the tag elements are included

The Cause

that is, this is what was causing the issue

<header>
    <script src="./mr.js"></script>
</header>
<body>
    <mr-app>
         ...
         <mr-foo>...</mr-foo>
         ...
    </mr-app>
    <script>
          ...
          class MRFoo extends MREntity { ... }
          ...
    </script>
</body>

so the <mr-foo> tag would be hit since it's not on async or defer, > even if the import script for mrjs and the construction script for > MRFoo have defer in their tag.

doing the onload for <script src="./mr.js" onload="constructMRFoo()"></script> (that was noted in the previous comment) works just because it ties MRFoo's implementation timing to mrjs's timing before the rest of the body gets fully filled out (even though the body is already fully read)

The Fix

to not require that, we just need to do the following to make sure the <mr-foo> html element inside <mr-app> is happy just like everything else:

<header>
    <script src="./mr.js"></script>
    <script>
          ...
          class MRFoo extends MREntity { ... }
          ...
    </script>
</header>
<body>
    <mr-app>
         ...
         <mr-foo>...</mr-foo>
         ...
    </mr-app>
</body>

Originally posted by @hanbollar in Volumetrics-io/mrjs#619 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions