Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code split loading[馃悶] #6028

Closed
primozs opened this issue Mar 18, 2024 · 2 comments
Closed

Code split loading[馃悶] #6028

primozs opened this issue Mar 18, 2024 · 2 comments
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@primozs
Copy link

primozs commented Mar 18, 2024

Which component is affected?

Qwik Runtime

Describe the bug

"@builder.io/qwik": "^1.5.1",
"@builder.io/qwik-city": "^1.5.1",

Writing onClick$ handlers in some cases loads js before event actually happens.
I was expecting that code would load on actual click event.

`
<button
onClick$={() => {
console.log('no javascript is loaded on page load only on click');
}}
>
test1

  <button
    onClick$={() => {
      isOpenSig.value = true;
    }}
  >
    javascript loaded on page load, instead of on click
  </button>

  {/* no javascript loaded on page load, mostly not possible workaround */}
  {isOpenSig.value && (
    <button
      onClick$={() => {
        isOpenSig.value = false;
      }}
    >
      close
    </button>

`
using signals or functions from custom reusable hook in onClick handler, loads even more js, before onClick event actually happens

sometimes hook can be rewritten in normal function then code is again not loaded before event actually happens.

Is this expected or its a bug?

Reproduction

https://stackblitz.com/edit/qwik-starter-suaufp?file=src%2Froutes%2Findex.tsx

Steps to reproduce

try different button examples one by one and check network tab

System Info

System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 17.87 GB / 31.07 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v20.10.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 8.12.1 - ~/.local/share/pnpm/pnpm
    bun: 1.0.26 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 122.1.63.174
    Chrome: 122.0.6261.128

Additional Information

No response

@primozs primozs added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Mar 18, 2024
@wmertens
Copy link
Member

Loading JS on click would cause noticable lag.

In dev mode, Qwik fetches JS on hover, and in production it fetches when the component is visible.

See the advanced docs for more information.

Closing as this is expected, but thanks for reporting concerns!

@wmertens wmertens closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
@primozs
Copy link
Author

primozs commented Mar 18, 2024

Thx for explanation but in production it is not just fetching when the component is visible but like I tried to describe.
If the code is not touching qwik it si loading on click.
Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants