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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Solve the Problem of Repeated Loading of Scripts #100

Open
csq2018 opened this issue Oct 15, 2019 · 3 comments
Open

How to Solve the Problem of Repeated Loading of Scripts #100

csq2018 opened this issue Oct 15, 2019 · 3 comments

Comments

@csq2018
Copy link

csq2018 commented Oct 15, 2019

(CV ON%%{%T}6`KPWVCD)FN
SH4(W DV6Q{K6SRW)4LK J9

Every time I click to trigger the _confirm page, I insert confirm.js how to solve this situation?

@csq2018 csq2018 changed the title 如何解决脚本重复加载的问题 How to Solve the Problem of Repeated Loading of Scripts Oct 15, 2019
@amorey
Copy link
Member

amorey commented Oct 15, 2019

What is the desired behavior? On the second click do you want to execute the callback without loading the script?

@bhawan-eco
Copy link

I have the same issue. multiple visits to a page causes repeated download/adding or same file by LoadJS.
Is there a way to remove the previous file before re-adding them?

@amorey
Copy link
Member

amorey commented Jan 13, 2020

You can use the .isDefined() method:

if (!loadjs.isDefined('foo')) {
  loadjs('/path/to/foo.js', 'foo', function() { /* foo.js loaded */})
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants