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

Image loading and error handling #91

Open
hkvstore opened this issue May 16, 2019 · 2 comments
Open

Image loading and error handling #91

hkvstore opened this issue May 16, 2019 · 2 comments

Comments

@hkvstore
Copy link

hkvstore commented May 16, 2019

I'd like to report 2 issues I found when playing with this excellent script:

  1. The script will insert image tag into <head>. Since the onload/onerror events will be fired after setting src, it might be better not to append the image to <head>.

  2. I accidentally passed a blank array as paths to loadjs(), it could pass the loadFiles() without firing callbackFn(), the subsequent loading process was therefore skipped. It would be nice if some error handling about that can be added.

Thank you for creating such a good script.

@amorey
Copy link
Member

amorey commented May 23, 2019

Happy to hear you like LoadJS! In terms of your issues, what's the disadvantage to inserting image tags into <head>? I tested it across browsers and didn't see any issues.

Let me think about the error handling for blank arrays some more...

@wklau2006
Copy link

wklau2006 commented May 23, 2019

Thank you for your reply. I didn't see any issues with Chrome too, but as mentioned, the onload/onerror events will be fired after setting src, preloading is done, no need to do more. I understand it needs to add extra code (e.tagName != "IMG") to distinguish images but this will keep the DOM clean. Only a tiny suggestion to make loadjs even better. Thanks.

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